Split class across multiple files

Terry Reedy tjreedy at udel.edu
Fri Nov 20 21:26:33 CET 2009


eric.frederich wrote:
> I have a class which holds a connection to a server and a bunch of
> services.
> In this class I have methods that need to work with that connection
> and services.
> 
> Right now there are about 50 methods some of which can be quite long.
>>From an organizational standpoint, I'd like to have method
> implementations in their own files.
> 
> Is this possible?

A method is just function that is a class attribute.


from somemethod import somemethod # has def somemethod

class Huge:
   somemethod = somemethod

# or

class Huge:
   defs
   ...

Huge.somemethod = somemethod

>  It is recommended?  Should I just stop worrying
> about it and have a 5,000 line class?

I suspect some refactoring would be useful.




More information about the Python-list mailing list