New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inaccurate docs on import
behaviour
#77521
Comments
The docs https://docs.python.org/3/tutorial/modules.html#the-module-search-path describe:
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? |
"built-in modules" has the specific meaning of modules that are compiled in to the python executable. It doesn't mean modules in the standard library. See https://docs.python.org/3.6/library/sys.html#sys.builtin_module_names Python 3.6.4 (default, Jan 7 2018, 15:53:53)
[GCC 6.4.0] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.builtin_module_names
('_ast', '_codecs', '_collections', '_functools', '_imp', '_io', '_locale', '_operator', '_signal', '_sre', '_stat', '_string', '_symtable', '_thread', '_tracemalloc', '_warnings', '_weakref', 'atexit', 'builtins', 'errno', 'faulthandler', 'gc', 'itertools', 'marshal', 'posix', 'pwd', 'sys', 'time', 'xxsubtype', 'zipimport') |
Thanks, I thought it might be something like that. Would it be worth clarifying the distinction in the docs? It was certainly surprising to me that |
If you have a suggested improvement, please create a pull request. Thanks! |
…ythonGH-92438) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> (cherry picked from commit 859250c) Co-authored-by: slateny <46876382+slateny@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
…ythonGH-92438) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> (cherry picked from commit 859250c) Co-authored-by: slateny <46876382+slateny@users.noreply.github.com>
…ythonGH-92438) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> (cherry picked from commit 859250c) Co-authored-by: slateny <46876382+slateny@users.noreply.github.com>
) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> (cherry picked from commit 859250c) Co-authored-by: slateny <46876382+slateny@users.noreply.github.com>
) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> (cherry picked from commit 859250c) Co-authored-by: slateny <46876382+slateny@users.noreply.github.com>
) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> (cherry picked from commit 859250c) Co-authored-by: slateny <46876382+slateny@users.noreply.github.com>
…ythonGH-92438) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> (cherry picked from commit 859250c) Co-authored-by: slateny <46876382+slateny@users.noreply.github.com>
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: