[Tutor] Keeping change-in-place vs. copy methods straight

Emile van Sebille emile at fenx.com
Tue Apr 29 00:15:39 CEST 2014


On 4/28/2014 11:45 AM, taserian wrote:

> Is there some sort of rule-of-thumb to determine if a function is
> in-place or returns a value?

my rule of thumb is to ask:


Python 2.7.5 (default, May 15 2013, 22:44:16)
[MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
 >>> help([].sort)
Help on built-in function sort:

sort(...)
     L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*;
     cmp(x, y) -> -1, 0, 1

 >>> help([].reverse)
Help on built-in function reverse:

reverse(...)
     L.reverse() -- reverse *IN PLACE*

 >>>



The *IN PLACE* tells me.

HTH,

Emile



More information about the Tutor mailing list