Python Gotcha's?

John Nagle nagle at animats.com
Sun Apr 8 00:01:37 EDT 2012


On 4/4/2012 3:34 PM, Miki Tebeka wrote:
> Greetings,
>
> I'm going to give a "Python Gotcha's" talk at work.
> If you have an interesting/common "Gotcha" (warts/dark corners ...) please share.
>
> (Note that I want over http://wiki.python.org/moin/PythonWarts already).
>
> Thanks,
> --
> Miki

A few Python "gotchas":

1.  Nobody is really in charge of third party packages.  In the
Perl world, there's a central repository, CPAN, and quality
control.  Python's "pypi" is just a collection of links.  Many
major packages are maintained by one person, and if they lose
interest, the package dies.

2.  C extensions are closely tied to the exact version of CPython
you're using, and finding a properly built version may be difficult.

3.  "eggs".  The "distutils" system has certain assumptions built into
it about where things go, and tends to fail in obscure ways.  There's
no uniform way to distribute a package.

4.  The syntax for expression-IF is just weird.

5.  "+" as concatenation.  This leads to strange numerical
semantics, such as (1,2) + (3,4) is (1,2,3,4).  But, for
"numarray" arrays, "+" does addition.  What does a mixed
mode expression of a numarray and a tuple do?  Guess.

5.  It's really hard to tell what's messing with the
attributes of a class, since anything can store into
anything.  This creates debugging problems.

6.  Multiple inheritance is a mess.  Especially "super".

7.  Using attributes as dictionaries can backfire.  The
syntax of attributes is limited.  So turning XML or HTML
structures into Python objects creates problems.

8.  Opening a URL can result in an unexpected prompt on
standard input if the URL has authentication.  This can
stall servers.

9.  Some libraries aren't thread-safe.  Guess which ones.

10. Python 3 isn't upward compatible with Python 2.

				John Nagle





More information about the Python-list mailing list