Python: the drain snake of programming.

May 25, 2006 14:04

Every once in a while, someone notices I don't like Python much and wants an itemized list of reasons. It's not very easy to come up with such a thing on demand. I don't usually sit around making lists of reasons I dislike a given programming language, believe it or not, so I don't usually have such reasons in front of me. The short, flippant ( Read more... )

Leave a comment

Comments 15

(The comment has been removed)

apotheon May 25 2006, 20:35:09 UTC
AIM, ICQ, MSN Messenger, Y!M, email . . .

Reply

(The comment has been removed)

apotheon May 25 2006, 21:04:03 UTC
I did.

Reply


cluebyfour May 25 2006, 20:51:39 UTC
I know nothing about python, but is it correct to assume that self is like this in other languages? Wouldn't it be implicit and thus optional, or must it be explicit in python?

Reply

apotheon May 25 2006, 21:01:28 UTC
My understanding is that there's a "simple" (relative term) set of rules for when it's optional and when it's not, and sometimes when optional you're supposed to use it anyway because in Python there may occasionally be more than one way to do it, but only one of them is considered "right".

self is indeed like this, or even me, in some other languages.

Reply


ex_req431 May 25 2006, 20:56:30 UTC
Egregious overuse of "self"?

hahah

Reply

apotheon May 25 2006, 21:04:21 UTC
Amused?

Reply

ex_req431 May 25 2006, 21:18:43 UTC
very much so, darling

Reply

cluebyfour May 25 2006, 22:37:19 UTC
Obviously, in python you have to touch your self a lot.

Oh, I kill me.

Reply


scoth May 26 2006, 01:42:28 UTC
The OO python code I've encountered isn't nearly as horrendous as that; this behemoth isn't representitive of what python code usually looks like. It's really easy to write ugly code in any language.

As far as 'self' goes, it's generally considered good practice to explicitly reference the scope of the variable that you're using so that there's no confusion if you're referencing a local variable only valid for the current subroutine or a property that belongs to the instance of the object that you're using.

I can't do much without knowing more of the context but I've beautified part of that code for you. Is this less bleedy?

def getDefaults(self):
req = self.request().field
defaults = {
'active': req('active', 'true'),
'featured': req('featured', ''),
'categoryID': req('categoryID', ''),
'locationID': req('locationID', ''),
'year': req('year', str(DateTime.today().year)),
}

Reply

scoth May 26 2006, 01:48:01 UTC
like reading a book without punctuation.

I take it you perlistas don't read much poetry ;-)

Reply

apotheon May 26 2006, 04:53:13 UTC
I read plenty. Good poetry tends to be very easy to follow, even without punctuation - more like Ruby than Python.

Reply

apotheon May 26 2006, 06:05:08 UTC
. . . and I take it you haven't heard of Perl Poetry.

Reply


Leave a comment

Up