Everything sux

Thursday, September 02, 2004

I Wish I Was in Y3K

Actually I just wish I had python 3k.
As of current python 2.4 there are a lot of partially overlapping features that really should be cleaned up. Old style classes vs new style, list comprehension vs gen exp, dict.items vs dict.iteritems and so on.

And damn, there are things that are so utter stupid:


is the syntax that almost any scripting language on earth uses too launch external commands. Ugly, I know.
Python has that too. And it means : repr(foo)
Why the hell?

Not to mention print as a keyword. Man, that is so nonsensish, but I could accept it if we did not have
print >>somefile

This, is the absurd thing. Anyway I don't even really feel assert is a good thing as a keyword, but I can quite accept it..

But, hey, did I talked about for..else ?
Yeah, I mean it:

for i in foo:
What of a control statement is this? When damn the else is executed?

Well, this is quite obscure.
Luckily we can use the great

while (cond):

Finally, not that I think this is much better but somewhat makes more sense:


Try to guess when the else is executed. Please do not read the manual.

I guess Guido was drunk when thinking this. I mean there is no case/switch statement and there is this?

BTW I understand that you can't break all the code out there.
I just wish python was better thought out. Why introducing list comp and generators in the same release?
It is quite obvious that evryone wants gen comprehension!

Also, I really think that a simple lazy keyword could have been a better thing to put in instead of gen exp. Much more general, and useful. Several "strict" languages had something like this for a while, and it has proven useful and good. Maybe in year 3k..


  • Well, I'm giving up on the else: examples. And I've never liked print either, except that having an expedient way to write to the console is imperative for a scripting language, so I'm willing to forgive it. Much better than system.out.println(), IMO.

    -- Gordon Weakliem

    By Anonymous Anonymous, at September 3, 2004 at 9:07 AM  

  • for..else and while..else aren't very intuitive, agreed. But try..except..else is quite useful and understandable as well. The 'else' block is executed if no exception is raised. Note that your example (try..except..else..finally) isn't legal Python, by the way... 'try' can be followed by either 'except' or 'finally', but not both.

    By Anonymous Anonymous, at September 4, 2004 at 6:45 PM  

  • yes I agree that try..else makes more sense.

    But wow, I never realized that except..finally was illegal syntax.
    Could you point out to an explanation of why this syntax is not allowed?

    By Blogger verbat, at September 5, 2004 at 3:06 AM  

  • http://www.talkaboutprogramming.com/group/comp.lang.python/messages/247177.html

    By Anonymous Anonymous, at September 11, 2004 at 7:02 PM  

Post a Comment

<< Home