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

16,252

Solution 1

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.

Solution 2

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

Are you asking about the import statement?

Share:
16,252
crackity_jones
Author by

crackity_jones

Just trying to figure it all out

Updated on June 16, 2022

Comments

  • crackity_jones
    crackity_jones almost 2 years

    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