This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author sam_b
Recipients docs@python, sam_b
Date 2018-04-23.09:51:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1524477096.11.0.682650639539.issue33340@psf.upfronthosting.co.za>
In-reply-to
Content
The docs https://docs.python.org/3/tutorial/modules.html#the-module-search-path describe:

> When a module named spam is imported, the interpreter first searches for a built-in module with that name. If not found, it then searches for a file named spam.py in a list of directories given by the variable sys.path. sys.path is initialized from these locations:

> -   The directory containing the input script (or the current directory when no file is specified).
> -   PYTHONPATH (a list of directory names, with the same syntax as the shell variable PATH).
> -   The installation-dependent default.


However, it seems like "the directory containing the input script" is checked *before* the standard library:

➜  tmp more logging.py
def foo():
    print('bar')
➜  tmp python
Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import logging
>>> logging.foo()
bar
>>> logging.WARNING
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'WARNING'
>>> 


Am I misunderstanding the docs?
History
Date User Action Args
2018-04-23 09:51:36sam_bsetrecipients: + sam_b, docs@python
2018-04-23 09:51:36sam_bsetmessageid: <1524477096.11.0.682650639539.issue33340@psf.upfronthosting.co.za>
2018-04-23 09:51:35sam_blinkissue33340 messages
2018-04-23 09:51:35sam_bcreate