Python: Define Classes in Packages

Posted by rfkrocktk on Stack Overflow See other posts from Stack Overflow or by rfkrocktk
Published on 2010-06-11T16:28:06Z Indexed on 2010/06/11 16:32 UTC
Read the original article Hit count: 435

Filed under:
|
|
|

I'm learning Python and I have been playing around with packages. I wanted to know the best way to define classes in packages. It seems that the only way to define classes in a package is to define them in init.py of that package. Coming from Java, I'd kind of like to define individual files for my classes. Is this a recommended practice?

I'd like to have my directory look somewhat like this:

recursor/
    __init__.py
    RecursionException.py
    RecursionResult.py
    Recursor.py

So I could refer to my classes as "recursor.Recursor," "recursor.RecursionException," and "recursor.RecursionResult.py". Is this "do-able" or recommended in Python?

© Stack Overflow or respective owner

Related posts about python

Related posts about class