Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Python handle classes being in separate files or are they all supposed to be in one file [duplicate]

Tags:

python

oop

I'm working on framework for testing some command line utilities. I want to create some classes to hold the different types of information more easily.

Python is fairly new to me so I'm not sure how you would handle this. Do you keep all your classes in one file with your main script or can you separate them into their own files and use them in your main script.

What is the paradigm for how you create multiple classes and use them in a single script?

Duplicate of How many python classes should I put in one file

like image 751
crackity_jones Avatar asked Nov 19 '08 17:11

crackity_jones


2 Answers

An answer from the duplicate question in the comments seems to answer my question. My understanding now is that you can add multiple classes to a separate file which would then be referred to as a module. Then you can import that module to use your classes.

like image 56
crackity_jones Avatar answered Oct 23 '22 09:10

crackity_jones


"What is the paradigm for how you create multiple classes and use them in a single script?"

Are you asking about the import statement?

like image 44
S.Lott Avatar answered Oct 23 '22 09:10

S.Lott