Thoughts about Python
PPNTWIMBXFFC at spammotel.com
Wed Feb 25 11:18:54 CET 2004
> I agree with you in all but that tuples are not
> necessary. Lists are the ones that are actually a
> hack for speed! :-)
Did you do some time profiling? I would be interested in the results.
> 3_ I prefer reading from left to right instead from right
> to left (it makes the parenthesis less confusing too).
> Compare to:
> Maybe I should learn Hebrew :-)
> Or we could always change it to
> $ lst|append -3|sort|reverse|len
> (in the end all are just filter patterns :))
This is an excellent example!
count = lst.append(3).sort().reverse().len()
is extremly readable but chaining of method calls is not supported in
Python. And I can live with it... Python has a more "expressive" path:
>>> lst = 
>>> count = len(lst)
The last line looks a bit odd after all the dot-notations to see a
function-call in the last line.
> 4_ If the python interpreter was smart enough sort()
> Inmutable types are usually less "magical" than their
> mutable counterpart.
> For instance:
> >>> lst1=[1,2]
> >>> lst2=lst1
> >>> lst2.append(3)
> >>> lst1
> [1, 2, 3]
> >>> lst2
> [1, 2, 3]
> >>> tup1=(1,2)
> >>> tup2=tup1
> >>> tup2=tup2+(3,)
> >>> tup1
> (1, 2)
> >>> tup2
> (1, 2, 3)
> Do you think a newbie would expect that a modification
> on one variable would have a effect on another?
More information about the Python-list