Linked Questions
14 questions linked to/from How does Python importing exactly work?
0
votes
0
answers
29
views
When I import sklearn am I only importing the base module? [duplicate]
My textbooks tells me to use the following import statements:
from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor
from sklearn.ensemble import RandomForestClassifier, ...
0
votes
0
answers
40
views
how does import in python work? When import does python run the code in it? [duplicate]
when I import a python file (let's call it x.py) to another file (let's call it y.py)
will the computer run x.py the moment I import it to y.py?
so that if a code is originally only called once in x....
6
votes
4
answers
5k
views
Proper way of implementing one function per file in Python
I'm developing a module to help me deal with files, that's the structure:
Archive/
| archive/
- __init__.py
- move.py
- rename.py
- mime_type.py
| setup.py
I'm designing one file - one ...
user avatar
user5526811
4
votes
1
answer
3k
views
Import a module function and required dependencies for it
How do I import and run a Python function and have all the dependencies it uses use the imports from the main Python file?
Main Python file:
from im import er
import time
er()
Python file with ...
user avatar
user12459825
3
votes
2
answers
2k
views
How to share global variable with lazy initialization?
Probably a very n00bish question but gets me every time...
Can someone explain to me why the following prints "None"?
test1.py
test = None
def init():
global test
test = 1
test2.py
from ...
0
votes
2
answers
2k
views
eclipse,python, NameError: name <MyModule> is not defined
I create the following package in eclipse via PyDev:
class Repository(object):
'''
classdocs
'''
def __init__(self):
'''
Constructor
'''
print("salaam"...
0
votes
1
answer
2k
views
Python - importing DNSTWIST to use its functions
I have a program that I wrote that uses this python code called dnstwist which can be found here: Dnstwist documentation
The python code for dnstwist itself can be found here: dnstwist.py
The way my ...
1
vote
2
answers
370
views
How to import in Python
i have following problem. In my project i have the below files:
main.py:
import general_functions
...
def main(argv):
make() # line 98
bake()
if __name__ == "...
1
vote
1
answer
517
views
Python dynamic loads modules/packages conflict
I want to load python(2.7 not 3.x) modules from source code dynamically using imp.load_source and if I dont't append the source code path to sys.path the local import can't work. In this case, How to ...
-1
votes
2
answers
84
views
What is the correct way to access an imported global variable in Python3.x?
Imagine a situation, in which you have two files say p1.py and p2.py.
p1.py:
a=5
p2.py:
from p1 import *
print(a) # NameError: name 'a' is not defined
print(p1.a) # NameError: name 'p1' is not ...
0
votes
2
answers
101
views
How can I access variable, which was assigned in another python script?
I have two scripts, let's say "reading" and "calculation".
Script "reading" has inside of it several functions, and reads data from csv files and creates pandas ...
-1
votes
1
answer
68
views
Is it a bad idea to have an import.py? [closed]
I'm working in Flask and have split up the code into different files and note that some times I will import the same thing in two different files
Would it be a bad to have a separate Python file ...
0
votes
1
answer
59
views
Access to imports made from separate files in python?
So I'm making a modular program for a security system in python, but I can't access modules I've imported in main.py from other scripts.
That is, say I have main.py that imports the random module.
I ...