newbie

Gerhard Häring gh at ghaering.de
Thu Mar 13 18:50:57 EST 2003


Max Khesin wrote:
> Hi all,
> I just started with the snake, coming from a C++ background (and what a cool
> snake it is!).
> Anyway, is method nesting possible in python, e.g.
> PrintLines(os.popen('dir').readlines().sort())
> or
> PrintLines((os.popen('dir').readlines()).sort())
> even if sort() does not return a reference to self, are there methods that
> do and is it a common Python programming style?

No, list methods (like sort) don't return the original list. It's
common to use a temporary variable for this. If you want to, you can
subclass list so sort returns the changed list, if you *really* want
this behaviour.

Wether lists methods should return their changed value has been
discussed at length on this list in the past, so you should be able to
use groups.google.com to review this discussion and the rationale for
the current behaviour.

Gerhard
-- 
mail:   gh at ghaering.de
web:    http://ghaering.de/




More information about the Python-list mailing list