Python becoming less Lisp-like

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Tue Mar 15 22:51:42 CET 2005


Valentino Volonghi aka Dialtone a écrit :
> Bruno Desthuilliers <bdesth.quelquechose at free.quelquepart.fr> wrote:
> 
>>It is actually. Ruby's syntax is mostly consistent and coherent, and 
>>there is much less special cases than in Python.
>  
> I'd be glad to know which special cases are you referring to.

A few examples:
- A statement is different from an expression (2 special cases instead 
of one general case).
- You can't use statements in a lambda
- to get the length of a sequence, you use len(seq) instead of seq.len()
- to call objects attributes by name, you use [get|set]attr(obj, name 
[,value]) instead of obj.[get|set]attr(name [,value])
- if x is a class attribute of class A and a is an instance of A, 
a.x=anyvalue create a new instance attribute x instead of modifying A.x
- sequence methods that modify the sequence in place return None instead 
of returning self - ok, I know the rational for this one, but I still 
dont like it, and still count it as a special case since when using a 
'destructive' sequence method I can't chain it with non-destructive 
method calls.
- object.__getattr__ (if it exists...) is called only when attribute 
name is not found. object.__setattr__ (if it exists...) is always called.
- functions are not methods
- old-style classes vs new-style classes

Also, Python enforce some coding style (indentation) but not some others 
(capitalization for example). So you always have to check, on a lib by 
lib base, what style has been used (I personnaly don't give a damn 
whether I use underscore_all_lower or mixedCaps, but consistency is 
useful, even more when there's such a huge stdlib). Worst, the base 
class for new style classes is all lower ('object') when the usual 
convention is to use CamelCase for classes.

> Please note that you wrote "much less" which means there are probably so
> many that you weren't able to count them.

I'm not able to count them all, since a good part of them are not carved 
in my poor little brain - I just deal with them day after day. I love 
Python and find it one of the best languages around, but the truth is 
that it has warts - like any other language - and no one can honnestly 
deny it. Some are on the way to disappear (the type unification is a 
good thing in intself, even if it actually leads to having 2 more or 
less compatible object models...)

Regards,
Bruno



More information about the Python-list mailing list