James H wrote:
Is that the same problem with using the len function on sequences
> and open on files, or is it different?
I don't think so. I'm not sure which problem you are referring to with
these?
Neither return None...
But a python list is mutable. I'm hardly an expert, but the idea is
you are modifying the list. Why would you create another copy of
the same list via a return statement?
You wouldn't you'd return the same, now-modified, object.
James R wrote:
I don't see this as a weakness but a strength.
It cuts back on confusion and extraneous variables.
It creates confusion too. Look at how many posts we get
because people try to do things like:
mylist = mylist.sort()
Actually it can introduce extraneous variables because
you need a temp to hold the modified list while you perform the extra
operations. With method chaining you do it all on one line.
Now the good news is that in Python you can use one variable to hold
both the intermediate list and the final result, so its not often a new
variable just a double use of a single one.
I suspect the value of this is only apparent if you have
used Smalltalk :-)
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor