Re: Thoughts about Python
> I agree with you in all but that tuples are not[color=blue]
> necessary. Lists are the ones that are actually a
> hack for speed! :-)[/color]
Did you do some time profiling? I would be interested in the results.
[color=blue]
> 3_ I prefer reading from left to right instead from right
> to left (it makes the parenthesis less confusing too).
> Compare to:
>
> count=len(rever sed(sorted(appe nded(lst,3)))).
>
> 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 :))[/color]
This is an excellent example!
count = lst.append(3).s ort().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:
[color=blue][color=green][color=darkred]
>>> lst = []
>>> lst.append(3)
>>> lst.sort()
>>> lst.reverse()
>>> count = len(lst)[/color][/color][/color]
The last line looks a bit odd after all the dot-notations to see a
function-call in the last line.
[color=blue]
> 4_ If the python interpreter was smart enough sort()
> [...]
> Inmutable types are usually less "magical" than their
> mutable counterpart.
>
> For instance:
>[color=green][color=darkred]
> >>> lst1=[1,2]
> >>> lst2=lst1
> >>> lst2.append(3)
> >>> lst1[/color][/color]
> [1, 2, 3][color=green][color=darkred]
> >>> lst2[/color][/color]
> [1, 2, 3][color=green][color=darkred]
> >>> tup1=(1,2)
> >>> tup2=tup1
> >>> tup2=tup2+(3,)
> >>> tup1[/color][/color]
> (1, 2)[color=green][color=darkred]
> >>> tup2[/color][/color]
> (1, 2, 3)[color=green][color=darkred]
> >>>[/color][/color]
>
> Do you think a newbie would expect that a modification
> on one variable would have a effect on another?[/color]
Good point.
Thanx,
Marco
> I agree with you in all but that tuples are not[color=blue]
> necessary. Lists are the ones that are actually a
> hack for speed! :-)[/color]
Did you do some time profiling? I would be interested in the results.
[color=blue]
> 3_ I prefer reading from left to right instead from right
> to left (it makes the parenthesis less confusing too).
> Compare to:
>
> count=len(rever sed(sorted(appe nded(lst,3)))).
>
> 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 :))[/color]
This is an excellent example!
count = lst.append(3).s ort().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:
[color=blue][color=green][color=darkred]
>>> lst = []
>>> lst.append(3)
>>> lst.sort()
>>> lst.reverse()
>>> count = len(lst)[/color][/color][/color]
The last line looks a bit odd after all the dot-notations to see a
function-call in the last line.
[color=blue]
> 4_ If the python interpreter was smart enough sort()
> [...]
> Inmutable types are usually less "magical" than their
> mutable counterpart.
>
> For instance:
>[color=green][color=darkred]
> >>> lst1=[1,2]
> >>> lst2=lst1
> >>> lst2.append(3)
> >>> lst1[/color][/color]
> [1, 2, 3][color=green][color=darkred]
> >>> lst2[/color][/color]
> [1, 2, 3][color=green][color=darkred]
> >>> tup1=(1,2)
> >>> tup2=tup1
> >>> tup2=tup2+(3,)
> >>> tup1[/color][/color]
> (1, 2)[color=green][color=darkred]
> >>> tup2[/color][/color]
> (1, 2, 3)[color=green][color=darkred]
> >>>[/color][/color]
>
> Do you think a newbie would expect that a modification
> on one variable would have a effect on another?[/color]
Good point.
Thanx,
Marco
Comment