xxxInPlace or xxxCopy?

Andrej Mitrovic andrej.mitrovich at gmail.com
Wed Jan 19 20:03:26 PST 2011


One common mistake newbies make in Python is calling the sorted method
and expecting it to sort in place:

>>> x = [3, 2, 1]
>>> sorted(x)
[1, 2, 3]    < sorted returned a new list
>>> x
[3, 2, 1]    < x stayed the same
>>>

There are a few functions in the Python lib that have "InPlace" added
to their names to avoid confusion, so it's not a new convention and it
seems like a good way to go.


More information about the Digitalmars-d mailing list