Python Gotcha's?

MRAB python at mrabarnett.plus.com
Sat Apr 14 19:14:57 EDT 2012


On 14/04/2012 23:47, Bryan wrote:
> Miki Tebeka wrote:
>>  If you have an interesting/common "Gotcha" (warts/dark corners ...) please share.
>
> Python 3(K) likes to use the same '.py' file extension as its
> incompatible predecessors, and in some/many/most *nix implementations,
> it likes to install in the same place. Python 3 is an improvement upon
> Python 2, but Python went from, "sure... Python just works," to,
> "well... that depends... which Python?"
>
> I missed the 1 to 2 transition. I'm not exactly a Python newbie, but
> Python 1.5.2 was dead an buried by the time I met the snake^H^H^H^H^H
> group of daffy English k-ni-ghits.
>
> We knew that there was no painless path from where we were to where we
> saw to be better, and the Python community and our BDFL made many wise
> decisions toward the Python 3 transition. This particular matter, we
> botched. I am too late in speaking up, so I'm as much blame as anyone.
> Something to keep in mind for Python 4.
>
I could also mention the strip/lstrip/rstrip methods. They accept a
string argument which is treated as a _set_ of characters to be
stripped from the string (sets were a later addition). Newbies
sometimes wonder why, for example, "test.txt".strip(".txt") returns
"tes" and not "test". The transition to Python 3 would've been a good
time to change that, although if the argument could be a set of
multicharacter strings then the order in which they are stripped would
matter, so perhaps a tuple of strings, like with the startswith and
endswith methods, would've been better.

I didn't think of it until it was too late...



More information about the Python-list mailing list