Linked Questions

2659 votes
41 answers
3.9m views

I have this folder structure: application ├── app │   └── folder │   └── file.py └── app2 └── some_folder └── some_file.py How can I import a function from file.py, from within ...
Ivan's user avatar
  • 31.4k
969 votes
20 answers
1.7m views

I have a directory that stores all the .py files. bin/ main.py user.py # where class User resides dir.py # where class Dir resides I want to use classes from user.py and dir.py in main.py. ...
Bin Chen's user avatar
  • 63.6k
2 votes
6 answers
34k views

I am working with python3 and Ubuntu 18.04 and trying to install a python package named "pyimagesearch". it is not possible to install using pip command or apt-get install. I Googled to see how to ...
elly's user avatar
  • 325
8 votes
1 answer
28k views

Im new to python and have looked at various stack overflow posts. i feel like this should work but it doesnt. How do you import a class from another file in python? This folder structure src/example/...
slipperypete's user avatar
  • 6,374
0 votes
2 answers
9k views

so I have a data cleaning project that looks something like this: import math import os import pandas as pd import math class CustomDataFrame(): code class CustomDataFrameItem(): code ...
zhangruibo101's user avatar
0 votes
1 answer
1k views

I am currently writing a UI script for Maya in Python. So, I have UI that has different tabs at the top and I do not want to put every single piece of code in the MainClass because that would be too ...
Eunice C's user avatar
1 vote
1 answer
1k views

I have a project that includes me using some SQL, I am wondering how can I call a function in the DB file? class testing_db(commands.Cog): def __init__(self, bot): self.bot=bot async ...
byggmesterPRO's user avatar
1 vote
2 answers
1k views

I am new in Python programming. I have property consist of getter and setter in a class in file A. class Histogram: def getHue(self): return self.value def setHue(self, value): ...
Ines's user avatar
  • 11
1 vote
1 answer
197 views

I have three file .py. Main.py, one_file.py, second_file.py. In one_file.py, I have a class named Create. In the main.py I have something like this: import one_file var = input("yes or no?") if var =...
John_python's user avatar
0 votes
1 answer
161 views

My older structure is: In a file, I'm doing: from CodeModel import CodeModel codemodel = CodeModel.CodeModel() But that seems redundant. Is there a cleaner way to import CodeModel without having to ...
Shamoon's user avatar
  • 43.9k
1 vote
1 answer
116 views

I am learning python and coming from a java/kotlin background i am tryin to figure out how to use a class defined in another file invoke the functions inside it? Here is my class: class Practise: ...
Jono's user avatar
  • 18.2k
-1 votes
1 answer
87 views

I have a module called generalPy and i want to access the python files in that folder. So i import it:from generalPy import * The specific one i want to access is called fractions.py. It has a class ...
Jonas's user avatar
  • 1
0 votes
1 answer
122 views

Im trying to import Class1 into Class2 as below. Im getting the following error importError : cannot import name 'Class1' class Class1: def __init__(self, list1, list2, list3): self.Var1= ...
user avatar
0 votes
3 answers
99 views

Suppose I have a file structure like this one: test mammals Wolf.py wolfname.txt Zoo.py And inside Wolf.py I have: class Wolf: def __init__(self): with open('...
parsecer's user avatar
  • 5,249
0 votes
0 answers
29 views

tree get_info get_info ├── __init__.py ├── __pycache__ │   ├── __init__.cpython-38.pyc │   └── get_resources.cpython-38.pyc └── get_resources.py contents of get_resources.py class get_resource_info()...
Prab's user avatar
  • 514