.comment-link {margin-left:.6em;}

Sometimes I Wish That It Would Rain Here

Monday, May 05, 2008

"test" reserved word in python?

I just had a rather odd experience with python. I've got a module named "test" (specifically, a directory named "test" with an empty __init__.py file in it) with a couple other modules in it, including one called "test_sel_pref" (i.e., a source file "test/test_sel_pref.py"). I can do

import test

just fine, but the module doesn't seem to contain anything other than the usual (__class__, __doc__, __file__, etc.). if I try

from test import test_sel_pref

I get

ImportError: cannot import name test_sel_pref

after checking several things, I started wording if "test" wasn't some sort of reserved word in python. it's not on the list of python keywords or the list of python reserved words, and keyword.iskeyword('test') returns False. just in case, I tried renaming the directory to "testData." sure enough,

from testData import test_sel_pref

worked like a charm. I looked around, but couldn't find anything that talked about an existing test module that would block me from having a module called test. for now, renaming the directory did the trick, but I'd like to know what was going on here. any thoughts?

Labels: ,

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home