Best practice in organize classes into modules

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Fri Jan 9 11:34:55 CET 2009


Steven Woody a écrit :
> On Fri, Jan 9, 2009 at 4:54 PM, Bruno Desthuilliers
> <bruno.42.desthuilliers at websiteburo.invalid> wrote:
>> Steven Woody a écrit :
>>> On Fri, Jan 9, 2009 at 1:02 PM, James Mills
>>> <prologic at shortcircuit.net.au> wrote:
>>>> On Fri, Jan 9, 2009 at 2:57 PM, Steven Woody <narkewoody at gmail.com>
>>>> wrote:
>>>>> In C++/Java, people usually put one class into one file.  What's the
>>>>> suggestion on this topic in Python?  I so much interesting this
>>>>> especially when exception classes also involved.
>>>> Normally i group related functionality into the one module.
>>> Will that lead to too large source file size?
>> When the case happens, then you can safely refactor the module into a
>> package with submodules, and use the package's __init__.py to make it a
>> facade for the submodules so the refactoring is transparent for client code.
> 
> really a smart idea.

Mostly a common Python idiom.

>  Did you mean putting some 'import statement in
> __init__.py and use the old module name as the new package name?

Yes, you guessed.




More information about the Python-list mailing list