append on lists
Terry Reedy
tjreedy at udel.edu
Tue Sep 16 13:06:35 EDT 2008
Maric Michaud wrote:
> It is, please try to understand it, in python all expressions that mutate an
> object should return None,
You are over-generalizing. For builtin classes, mutation methods return
none. Guido recommends this as a general practice, but users may do
whatever they like in their own classes. In fact, people have been told
that if they do not like the built-in behavior, they should make their
own, possibly by subclassing.
For augmented assignment, in-place mutation followed by rebinding is
explictly allowed and done for lists.
> all expressions that return something, return a new object
Nonesense. There is nothing in the ref manual that says this and parts
that say otherwise.
> there are some noticeable exceptions :
They are only exceptions to your rule, not to the language specification.
More information about the Python-list
mailing list