Linked Questions

14 questions linked to/from How does Python importing exactly work?
0 votes
0 answers
29 views

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

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

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
4 votes
1 answer
3k views

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
3 votes
2 answers
2k views

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 ...
urban's user avatar
  • 5,730
0 votes
2 answers
2k views

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

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

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__ == "...
FotisK's user avatar
  • 1,197
1 vote
1 answer
517 views

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 ...
YuLun's user avatar
  • 43
-1 votes
2 answers
84 views

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

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 ...
Sirakan's user avatar
-1 votes
1 answer
68 views

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 ...
norgia 's user avatar
0 votes
1 answer
59 views

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 ...
Jckxxlaw's user avatar
  • 391