Lately, I have recurring WTF moments when working with Python. I'm still more or less a novice in Python, as I started to use it in my day job last year, so sometimes it could be blamed to ignorance.
Today I was writing some code that takes any file descriptor as argument,
and thought it could be nice to accept also objects that represent one. But it
seems there is no common ancestor to file objects and socket objects, for
example. In Perl, I'd just check for IO::Handle
.
Then, I wrote code to check if a passed argument was a socket, or a file
descriptor to one, with some obvious check: isinstance(s,
socket.socket)
. WRONG, when you create sockets with
socketpair
, they are of an undocumented type which is not a
descendant of socket, nor of SocketType! (There is a patch for this since 2007)
In general, I have found a lack of any reasonable object hierarchy, and many inconsistencies in the low-level interfaces, which is a pity, because Python is in general quite tidy. Comparing with Perl is unavoidable, and I would have expected that Python had learnt more from it.
Another thing that amazes me is the lack of anything like CPAN, which is one of the reasons Perl was so successful. The cheese factory doesn't come close, as you need to publish your files somewhere else, there is no automated testing, no automatically generated documentation, or anything that requires access to the source code.
In Perl-land, many people loathe the venerable MakeMaker, and some of the alternatives are ugly as hell. The Python equivalent (or so) to Makemaker, distutils, looks to me like a bad joke: advanced customisation is black magic (if possible at all), and doesn't provide absolutely basic things like running your unit tests! After fighting with it for some days, I decided to go back writing my own Makefile and calling distutils just to build and install.