Rant (was Re: x*x if x>10

Terry Reedy tjreedy at udel.edu
Sun Jul 27 23:26:24 CEST 2008



DaveM wrote:
> On Sun, 27 Jul 2008 19:46:32 +0200, "Diez B. Roggisch" <deets at nospam.web.de>
> wrote:
>> As a rule of thumb, don't return objects you didn't create inside a 
>> function from scratch.

Unless its job is specifically to get/fetch an object (reference 
thereto) from someplace the caller cannot or should not access.  But 
then it should probably not mutate the object before returning the 
reference.
> 
> I wish I'd had that advice when I started learning python. It would have
> saved me no end of grief.

I wish I had seen this 'rule' before too.




More information about the Python-list mailing list