Determine calling module's name

David Goodger dgoodger at bigfoot.com
Fri Aug 11 00:04:06 EDT 2000


on 2000-08-10 23:31, Roland Mas (mas at echo.fr) wrote:
> David Goodger (2000-08-10 22:49:20 -0400) :
>> on 2000-08-10 03:17, Roland Mas (mas at echo.fr) wrote:
>>> (file, line, func, None) = list [len (list) - 3]
>> ...
>>> (file, func, None) = whocalled ()
>> 
>> Um. Assigning to None. Bad idea. Side effects. Ouch! Please be careful!
> 
> Really?  What kind of side effects could that have?  I'm particularly
> looking for a memory leak somewhere, so I'm really interested.  I
> fixed the bug in my code, but I won't be able to test it before
> several hours, and anyway I'm interested.

Just that you've clobbered None in the namespace where you've done the
assignment. So you can't use its usual, useful, value (if x is None, return
None, etc.), at least not easily. It would be like doing:

>>> import math
>>> math.pi
3.14159265359
>>> math.pi = 3
>>> math.pi
3

Yes, you can do it. But why? it removes functionality, and what's the point?
(Legislation in a certain US state notwithstanding.)

Just use a temporary variable, like 'junk', instead.

-- 
David Goodger    dgoodger at bigfoot.com    Open-source projects:
 - The Go Tools Project: http://gotools.sourceforge.net
 (more to come!)




More information about the Python-list mailing list