By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,559 Members | 1,154 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,559 IT Pros & Developers. It's quick & easy.

Preventing modules to be read from current working directory

P: n/a
Is there a way to instruct Python to import modules from standard
library even if there is one with the same name in the current working
directory? I was trying to import BaseHTTPServer.py from standard
library but was prevented by a python file with the same name in
current working directory (but there was no __init__.py). Can I use
some warning switch to print a warning on stdout?

Thanks,
Sunpreet.

Nov 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
In article <11**********************@g43g2000cwa.googlegroups .com>,
ss******@gmail.com wrote:
Is there a way to instruct Python to import modules from standard
library even if there is one with the same name in the current working
directory? I was trying to import BaseHTTPServer.py from standard
library but was prevented by a python file with the same name in
current working directory (but there was no __init__.py). Can I use
some warning switch to print a warning on stdout?

Thanks,
Sunpreet.


Sure, just modify sys.path so the current directory is not included. See
the documentation for the sys module in the library reference for more
details.
Nov 22 '05 #2

P: n/a
Great, thanks.

Nov 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.