I need a little help here.
I'm developing some introductory material on Python for non-programmers.
The first draft includes this statement. Is this correct?
-----------------------------------------------------------------
When loading modules, Python looks for modules
in the following places in the following order:
* Python's built-in modules, including modules in the standard library
* in the /python23/Libs/site-packages directory
* the directory from which your main module was loaded
* in directories in PYTHONPATH
------------------------------------------------------------------
Thanks in advance! -- Steve Ferg 3 9446
Thanks.
It says """When a module named spam is imported, the interpreter
searches for a file named spam.py in the current directory, and then
in the list of directories specified by the environment variable
PYTHONPATH. ... When PYTHONPATH is not set, or when the file is not
found there, the search continues in an installation-dependent default
path; on Unix, this is usually .:/usr/local/lib/python.
Actually, modules are searched in the list of directories given by the
variable sys.path which is initialized from the directory containing
the input script (or the current directory), PYTHONPATH and the
installation-dependent default."""
Is the installation-dependent default path on Windows usually
Lib/site-packages?
If so, then it looks like my original search order was wrong,
and the correct search order (on Windows) is:
---------------------------------------------------------
* Python's built-in modules, including modules in the standard
library
* the directory from which your main module was loaded
* in directories in PYTHONPATH
* in the /python23/Libs/site-packages directory
--------------------------------------------------------
Is that correct?
Part of what is confusing me is that Lib/site-packages is pretty
poorly documented.
Stephen Ferg: It says """When a module named spam is imported, the interpreter searches for a file named spam.py in the current directory, and then in the list of directories specified by the environment variable PYTHONPATH. ... When PYTHONPATH is not set, or when the file is not found there, the search continues in an installation-dependent default path; on Unix, this is usually .:/usr/local/lib/python.
Actually, modules are searched in the list of directories given by the variable sys.path which is initialized from the directory containing the input script (or the current directory), PYTHONPATH and the installation-dependent default."""
Is the installation-dependent default path on Windows usually Lib/site-packages?
I guess it's more than that.
PythonWin 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit (Intel)] on
win32. import sys print sys.path
['','C:\\Python\\Python22\\lib\\site-packages\\Pythonwin',
'C:\\Python\\Python22\\lib\\site-packages\\win32',
'C:\\Python\\Python22\\lib\\site-packages\\win32\\lib',
'C:\\Python\\Python22\\lib\\site-packages', 'C:\\Python\\Python22\\DLLs',
'C:\\Python\\Python22\\lib', 'C:\\Python\\Python22\\lib\\lib-tk',
'C:\\Python\\Python22']
None of these directories qualify for any of the other categories, so
these must all be in the installation-dependent default.
If so, then it looks like my original search order was wrong, and the correct search order (on Windows) is:
--------------------------------------------------------- * Python's built-in modules, including modules in the standard library * the directory from which your main module was loaded * in directories in PYTHONPATH * in the /python23/Libs/site-packages directory --------------------------------------------------------
Is that correct?
Well no, I don't think so. The tutorial doesn't say that the modules in
the standard library are searched first. It says the current directory is
first, which you don't even mention. And the tutorial says sys.path is
searched, which may be modified by the program.
Why are you trying to rephrase the tutorial, when the tutorial is
perfectly clear?
Part of what is confusing me is that Lib/site-packages is pretty poorly documented.
It doesn't have to be, for ordinary users. My guess is the documentation
is in this area: http://www.python.org/sigs/distutils-sig/doc/
--
René Pijlman This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Peter Schwalm |
last post by:
I'd like to modify the python search path depending on the source
directory of the script being started. The reason is: I use a version
control system, and the python scripts and modules are...
|
by: Andrew Dalke |
last post by:
Is there an author index for the new version of the
Python cookbook? As a contributor I got my comp version
delivered today and my ego wanted some gratification.
I couldn't find my entries.
...
|
by: TokiDoki |
last post by:
Hello there,
I have been programming python for a little while, now. But as I am
beginning to do more complex stuff, I am running into small organization
problems.
It is possible that what I...
|
by: Jay |
last post by:
OK, I have this XML doc, i dont know much about XML, but what i want
to do is take certain parts of the XML doc, such as </title> blah
</title> and take just that and put onto a text doc. Then...
|
by: nojhan |
last post by:
I'm trying to embbed the python interpreter as a class attribute,
initializing it in the constructor, and finalizing in destructor.
The code is rather simple:
// base_path is an attribute of...
|
by: aznach |
last post by:
Hello!
I have a shared hosting account at GrokThis.net and have a problem with
the module order of the Python search path.
I'd like to use django's svn trunk instead of the...
|
by: Kurt B. Kaiser |
last post by:
Patch / Bug Summary
___________________
Patches : 342 open (-38) / 3712 closed (+54) / 4054 total (+16)
Bugs : 951 open (-14) / 6588 closed (+33) / 7539 total (+19)
RFE : 257 open...
|
by: david |
last post by:
You learn something new every day:
On my ubuntu, update-manager is supposed to use the python2.5
installed on /usr/bin. Well, I had subsequently installed a whole
bunch of stuff in /usr/local...
|
by: Anita Kean |
last post by:
Hello
I just downloaded the new python2.6 documentation,
full of hopes it would solve some basic mysteries for me.
I'm new to python, so please forgive my ignorance.
I've two questions.
1)...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
|
by: Ricardo de Mila |
last post by:
Dear people, good afternoon...
I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control.
Than I need to discover what...
|
by: ezappsrUS |
last post by:
Hi,
I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
|
by: jack2019x |
last post by:
hello, Is there code or static lib for hook swapchain present?
I wanna hook dxgi swapchain present for dx11 and dx9.
|
by: DizelArs |
last post by:
Hi all)
Faced with a problem, element.click() event doesn't work in Safari browser.
Tried various tricks like emulating touch event through a function:
let clickEvent = new Event('click', {...
| |