On Mon, 14 Jan 2002, Jason Orendorff wrote: > One of the examples in PEP 215 is a bit wrong, I think. > > >>> print $'\$a' > 5 > > This should output a backslash before the 5, because the > string '\$a' has a backslash character in it. You are correct. I'll make this change. > Also, for clarity, PEP 215 should explicitly specify > that the substitution only occurs once. [...] > Maybe there should also be examples demonstrating that $-strings > adopt the local namespace. Sure, that wouldn't hurt. More examples are a good idea. > Consider: > > def f(str): > # The argument 'str' masks the builtin str() function. > a, b = find_stuff(str) > print $'a = $a, b = $b' > return a, b > > It should be specified that $-strings do not use the local > "str" and "unicode" names to find str() and unicode() Good point. Perhaps it is better to simply describe a transformation using '%s' and '%' instead of 'str' and '+' to avoid this potential confusion altogether. -- ?!ng
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4