python-import
Force python to use an older version of module (than what I have installed now)
My employer has a dedicated module1 we use for internal unit / system test; however, the author of this module no longer works here and I have been asked to test some devices with it.[详细]
2023-03-14 22:26 分类:问答What is the most pythonic way to import modules in python
Can anyone suggest me what is the most pythonic way to import modules in python? Let me explain - i have read a lot of python code and found several different ways of how to import modules or if to b[详细]
2023-03-13 21:23 分类:问答Cyclic module dependencies and relative imports in Python
Suppose we have two modules with cyclic dependencies: # a.py import b def f(): return b.y x = 42 # b.py import a[详细]
2023-03-13 12:46 分类:问答Importing a long list of constants to a Python file
In Python, is there an analogue of the C preprocessor statement such as?: #define MY_CONSTANT 50 Also, I have a large list of constants I\'d like to import to several classes. Is there an analogue o[详细]
2023-03-12 14:40 分类:问答Python: Importing an "import file"
I am importing a lot of different scripts, so at the top of my file it gets cluttered with import statements, i.e.:[详细]
2023-03-09 16:55 分类:问答How to debug Python import failure
I have a directory structure: network/__init__.py network/model.py network/transformer/__init__.py network/transformer/t_model.py[详细]
2023-03-08 16:46 分类:问答Import urllib or urllib 2 in Python 2.7 failing with ImportError: cannot import name iskeyword [duplicate]
This question already has answers here: Importing installed package from script with the same name raises "AttributeError: module has no attribute" or an ImportError or NameError[详细]
2023-03-07 08:11 分类:问答Python * imports
I\'ve generally been told that the following is bad practice. from module import * The main reasoning (or so I\'ve been told), is that you could possibly import something you didn\'t want, and it c[详细]
2023-03-02 20:34 分类:问答Unexpected relative import behavior in Python
I ran into a very surprising relative import behavior today (unfortantely after nearly 4 hours of pulling my hair out).[详细]
2023-03-02 11:37 分类:问答How to reload python module imported using `from module import *`
I saw in this useful Q&A that one can use reload(whatever_module) or, in Python 3, imp.reload(whatever_module).[详细]
2023-02-22 00:22 分类:问答