What is my module name?
Carel Fellinger
cfelling at iae.nl
Thu Jun 28 14:45:29 EDT 2001
Clark C . Evans <cce at clarkevans.com> wrote:
> I have a module with a function below I
> use __name__ to return the module name.
> However, when I call the function from
> outside, it returns '__builtin__'. Is
I wonder how you get those results.
$ python
>>> __name__
'__main__'
$ cat a.py
def name(): return __name__
print "a:", name()
$ python a.py
a: __main__
$ cat b.py
import a
print "b", a.name()
$ python b.py
a: a
b: a
--
groetjes, carel
More information about the Python-list
mailing list