471,055 Members | 1,840 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,055 software developers and data experts.

Preventing modules to be read from current working directory

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
2 1467
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
Great, thanks.

Nov 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by saidev | last post: by
4 posts views Thread by Bob van der Poel | last post: by
3 posts views Thread by Paul Mc Gee | last post: by
11 posts views Thread by fortepianissimo | last post: by
14 posts views Thread by T. Crane | last post: by
reply views Thread by Martin P. Hellwig | last post: by
2 posts views Thread by marion | last post: by
2 posts views Thread by Aaron Scott | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.