473,386 Members | 1,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 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 1559
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: saidev | last post by:
A quick question, I'm about to recompile PHP, last time I compiled it with alot of modules, thinking that this time I should not need that many. Is there any tool(s) that could run under the...
4
by: Bob van der Poel | last post by:
I'm working on a moderately sized application and I'm planning on having a fair number of modules. The only question in my mind is: where do I put the modules ... and how do I let python know about...
3
by: Paul Mc Gee | last post by:
hi everyone i have just downloaded the latest version of postgresql and was doing the installation according to the article at http://www.faqs.org/docs/ppbook/x486.htm when i got to the point...
11
by: fortepianissimo | last post by:
Say I have the following package organization in a system I'm developing: A |----B |----C |----D I have a module, say 'foo', that both package D and B require. What is the best practice in...
14
by: T. Crane | last post by:
Hi, When troubleshooting code that's saved in a text file, I often find that I want to make a change to it, re-save it, then reimport it. However, just typing import myTestCode doesn't...
3
by: duyanning | last post by:
I have written a pyhton script that will process data file in current working directory. My script is in an different directory to data file. When I debug this script using pdb within emacs, emacs...
0
by: Martin P. Hellwig | last post by:
Hello all, I had some troubles in the past how to arrange my packages and modules, because I usually don't develop my stuff in the Lib\site-packages directory I have some troubles when importing...
2
by: marion | last post by:
I am working on a client/server, computer role-play game using Python. I want to gradually expand the game world by creating maps as individual py files in a map directory. I am a little foggy of...
2
by: Aaron Scott | last post by:
I've installed mod_python, and everything seems to be working, but it fails when I try to import another file into the file that's actually producing the output. I have these lines at the top of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.