On Oct 25, 1:32 pm, Tim Chase <python.l...@tim.thechases.com> wrote: > > If I just input dir(test) I don't get "a" in my list. > > >>>> import test > >>>> dir(test) > > ['__builtins__', '__doc__', '__file__', '__name__', '__package__', > > '__path__'] > > > I am using python 2.6 > > > Am I doing anything wrong? > > Are you importing the module you think you are? > > t...@rubbish:~/tmp$ echo "a=42" > test.py > t...@rubbish:~/tmp$ python2.5 > >>> import test > >>> dir(test) > ['__builtins__', '__doc__', '__file__', '__name__', 'a'] > > Granted this is 2.5 (the most current I have on my Debian box, > but I also tested in 2.3 and 2.4 which are also installed) > instead of 2.6 but they should all behave the same. If I remove > test.py/test.pyc, I get the following: > > t...@rubbish:~/tmp$ rm test.py test.pyc > t...@rubbish:~/tmp$ python2.5 > >>> import test > >>> dir(test) > ['__builtins__', '__doc__', '__file__', '__name__', '__path__'] > >>> test.__file__ > '/usr/lib/python2.5/test/__init__.pyc' > > because there's apparently a module named "test" in the standard > distribution that gets found instead. > > -tkc
Tim, You were right. When I renamed my test.py file into test77.py it worked perfectly well. Thank you. Is there a way to know which test.py it was importing? -- http://mail.python.org/mailman/listinfo/python-list