Quantcast
Channel: Python. Good, bad, evil -3-: Flow control exceptions
Viewing all articles
Browse latest Browse all 9

jpic at Wed, 05 May 2010 22:56:13 +0200

$
0
0
Hi Toby, Excellent articles! We must admit that ipython is really much more useful than PEAR::PHP_Shell. Part1: The first part looked like an article i had just read, by a Python programmer about PHP: http://spyced.blogspot.com/2005/06/why-php-sucks.html Anyway, many disagree with the first article of the series, the "missing braces" (and parenthesis and semicolons and -> ...). All coders i've seen coming from PHP or C++ to Python or Go have an impression of "fresh air" - except you of course :P Note that it is possible to reduce the annoyance of special characters with modified keyboard layouts like dvorak-code or dvorak-jpic. Part2: Spl is still a young extension and should be used with care, some BC breaks are commited and not added to the PHP5.3 BC breaks list. It is also poorly documented and ArrayObject for example is really a pain at the beginning (before you learn all its flaws). So, is it really fair to compare SPL? Part3: Unfortunately, only a handful of Python users will understand your point about exceptions. Even after a few years with Python, it still annoys me to be forced to "catch an exception" just to control the flow .... What happened to the standard "return -1" ? is your grandma hiding it? Actually, you've only got (unfortunnately again) half the thruth! Because Python users are too busy using exceptions for flow control: they actually (almost) *never* check for sanity of arguments! ie. If a string is passed instead of a float, the error will be revealed much later in the code .... I don't get why Python users don't do these simple sanity checks when they *know* that not doing it will make it harder for users to debug. That's obviously the "evil" part :P Finally, i hope you got the easter egg, try "import this" in the python console.

Viewing all articles
Browse latest Browse all 9

Latest Images

Trending Articles





Latest Images