php to eat, python to grow!

Just saw this gem on reddit:

Also, good luck on implementing an http-proxy in PHP, the damn thing would have to be huge, ugly and would require at least one PEAR lib to do it the right way.

And for some reason wordpress post by e-mail has a low google ranking, so I thought I should +1 that. Though I personally prefer a clunky interface to an ajax one any day.

Standard library granularity in python, argparse vs getopt

Is it ok that python has 2 modules for option parsing, 3-4 xml packages, 3 HTTPServer modules, etc? This issue hit me when contemplating the deprecation of getopt as a part of the inclusion of argparse. Whenever I want to parse xml/html I get overwhelmed by the options in the std-lib. I remember myself annoyed and confused by getopt/optparse both showing me 2 different ways of doing something so similar. As a newcomer to python, I wanted python to show me the right way of doing things.

So following that line of thought, getopt is the ugly way of doing option parsing. It imitates an option parsing flow that came from the old C days (and thus unpythonic), making it very attractive for people familiar with getopt/xgetopt. So what’s more important: easy learning curve or enforcing best practices?

I wanted to see how ugly getopt code looks so using google code search I found a few real life usage examples.

getopt sample code, or check out the search results yourself:

optparse sample code:

At first I thought the learning curve thing was important, but in the end, getopt is a very unpythonic module that I would rather not see any of my colleagues use at all, except for rare cases where an awful lot of flexibility is needed. For example, getopt could be an easy way to implement optparse, or a completely different alternative. For example¬†pyopt uses getopt in such a way. So IMHO getopt should be in the std-lib, but the documentation should have a very big sign saying “use the awesome optparse/argparse, this is a very simple parser with barely any of the features you probably need”.

Google Code Doesn’t Network

When I search for “pyopt” on google the first result is the PyPI page which is pretty amazing considering it didn’t exist before a few hours. The google code page for pyopt is nowhere to be seen, a search for “pyopt” gives only some mathematical optimization module. Strange stuff google, strange. Maybe I should’ve went with github.

update 15-11-2009: now I do get the top ranking search result on google for pyopt but zero results on yahoo search’s first page. Wtf is Peyote? So anyway the conclusion is it takes google at least a week to crawl google-code. Strange.

You Think You Know Pi…

Did you ever think you could compute pi to whatever digit you like? Given a computer, there is no algorithm that can infinitely print out the next digit of pi for ever. Any and all algorithms will eventually run out of memory and break. Sorry. Because your computer is a finite machine with a finite amount of states, eventually your algorithm must repeat itself and pi doesn’t. When I thought this up I was like “holy shit” at first but then I calmed down after realizing knowing pi to any digit was only for people with OCD’s anyway…

Where’s toString?

Why don’t python integers have a smart toString method like java/javascript? It’s easy to convert strings into numbers using int(str_whatever) or float(str_whatever) but to convert them back you have only the decimal system (using str(number) or “%d” % number). In case you want to convert to binary, base32, base36, base64, you’re gonna have to write your own conversion function. Batteries included?

Use either:

I added a feature request, lets see if it gets completely shot down:

Mirror’s Edge Review

I just finished this parkour-free-running-shooter game and it was insanely polished visually and mechanically. The only gripe I can say is that it gets old real quick, the gameplay has no depth and it’s always the same wall-jump puzzle. It starts out very promising because you learn every single cool thing about the game in a well thought out tutorialish first level. There are about 4 visual styles in the game, daytime rooftops, daytime streets, bright indoors and dark indoors. The story’s cute, but not too convincing. Did I mention the main character’s hot and has a matching hot sister?

It was a good game but next time around I’d like EA to give me something I can enjoy chewing. Maybe add a tricks/turbo system that helps you run/jump/fight. Oh and one more thing, there’s a slow-motion-matrix button which is absolutely useless, shoulda been removed from the game if it isn’t relevant.