[Tutor] 'in-place' methods
Alan Gauld
alan.gauld at freenet.co.uk
Sat Feb 18 00:50:58 CET 2006
>I think I understand this sorting-a-list 'in place' stuff, and things
> of that kind (reversing for example); but I am finding it very
> difficult to get used to, since sorting a list doesn't return the
> sorted list as a value, but simply does the work as a side effect.
If its any consolation I personally think this ois one of the
worst aspects of Python. Most of its features I either like
or can tolerate but this one just seems insane to me.
> Third question: is this in-place behavior of methods in effect
> restricted to lists, or are there other places I should be on the
> lookout for it?
The other place where a None return seems unintuitive is in
Tkinter. The layout manager methods(pack, grid etc) all return
None when most folks intuitively expect them to return the widget.
But I think the reason for that is that the underlying Tk code does
the same.
Alan G.
More information about the Tutor
mailing list