Directory separator in module name using '__import__()' cross platform difference

Follower follower at iname.com
Mon Jan 20 16:28:01 EST 2003


Hi,

Under Python 2.2.1 on Mandrake 9.0 the following code (in interactive
mode):

__import__("test/test_ds")

results in:

<module 'test/test_ds' from 'test/test_ds.pyc'>

But, under Windows it results in an 'ImportError', even if I change
the directory separator used.

Now, I realise it's illegal to specify a directory path when using the
'import' *statement*, but which of the two above behaviours is
"correct" for the '__import__' function?

Is there a way of having the Unix behaviour work under Windows?

Is this an known and/or intentional implementation difference?

Thanks,
Phil.




More information about the Python-list mailing list