Determine calling module's name
Christian Tanzer
tanzer at swing.co.at
Fri Aug 11 01:43:47 EDT 2000
David Goodger <dgoodger at bigfoot.com> wrote:
> 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!
Don't get carried away:
-------------------------------------------------------------------------------
Python 1.5.2 (#5, Jan 4 2000, 11:37:02) [GCC 2.7.2.1] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> def not_foo () :
... (f,g,None) = (1,2,3)
... return f,g
...
>>> print "%s" % None
None
>>> not_foo ()
(1, 2)
>>> print "%s" % None
None
>>> None==3
0
>>> None=3
>>> None==3
1
>>> print "%s" % None
3
>>>
-------------------------------------------------------------------------------
The name `None' is bound in the scope of the assignment. No effect is
visible outside that scope.
--
Christian Tanzer tanzer at swing.co.at
Glasauergasse 32 Tel: +43 1 876 62 36
A-1130 Vienna, Austria Fax: +43 1 877 66 92
More information about the Python-list
mailing list