[Python-Dev] unexpected import behaviour

Daniel Waterworth da.waterworth at gmail.com
Thu Jul 29 08:32:28 CEST 2010


Hi,

I'm not sure if this is a bug or not, I certainly didn't expect it. If
you create a file called test.py with the following contents,

class Test:
    pass

def test_1():
    import test
    print Test == test.Test

if __name__ == '__main__':
    test_1()

and then run it ($ python test.py), it'll print False. Now try:

$python
import test
test.test_1()

and it'll print True. Is this behaviour expected? What was the
rationale for it if is?

Thanks,

Daniel

-- 
active-thought.com


More information about the Python-Dev mailing list