is it possible to dividing up a class in multiple files?
Patrick Maupin
pmaupin at gmail.com
Tue Aug 8 00:48:58 EDT 2006
Diez B. Roggisch wrote:
> Martin Höfling wrote:
>
> > is it possible to put the methods of a class in different files? I just
> > want to order them and try to keep the files small.
>
> No, its not possible. What you can do is to create several classes and one
> that inherits from all of them.
>
> Better yet is to not write huge classes and getting rid of strange
> conventions or views that make the problem appear as such. To explain that:
> I've never felt the need to spread a class over several files - au
> contraire, I despise Java for forcing me to only have one top level class
> per file.
While refactoring to avoid huge classes is usually excellent advice, it
actually is possible (and sometimes even useful) to merge classes
without using inheritance.
See, for example,
http://www.webwareforpython.org/MiscUtils/Docs/Source/Files/MixIn.html
Regards,
Pat
More information about the Python-list
mailing list