I love Python, but a few things still bug me about it. I’ve bashed on several other technologies; here’s some Python bashing. In no particular order:
len()
should be a method on collections, not a built-in.- The GIL sucks, and it’s going to get suckier until someone fixes it, and that will be hard.
- (Mutable) default arguments are shared across function invocations:
def foo(bar=[])
. This one nails newbies all the time. (1) != (1,)
— the first is an integer, and the second a singleton tuple.2**29 in xrange(2**30)
should return instantly, like it does in Ruby, rather than iterating up to2**29
. In other words, range objects should have basic knowledge of their endpoints.- Decorator syntax is ugly and un-Pythonic. If I wanted
@
signs all over my code I would be using Perl. - No support for labeled break and continue. I continue to respectfully disagree with the rejection of my PEP.
- There’s a
copy()
method on the mutable dict and set types, but not one on list — the best solution is to writefoo[:]
, which is cryptic at best.
Update: This has started a pretty good discussion on Reddit. Many people correctly guessed that I’m using singleton in the mathematical sense, not in the sense of the programming pattern. The comments from Cairnarvon and tghw are particularly worth reading.