Splitting a class definition into several files?

Delaney, Timothy C (Timothy) tdelaney at avaya.com
Tue Nov 16 01:19:02 CET 2004

Jerry wrote:

> My "main" class is getting a bit long...Is it possble to split a
> class definition into several files and then import the pieces to get
> the whole definition? 

Well, one way is to use multiple inheritance:

    class RealClass_Part1:
        def method1 (self):

    class RealClass_Part2:
        def method2 (self):

    class RealClass (RealClass_Part1, RealClass_Part2):
        def __init__(self):

Tim Delaney

More information about the Python-list mailing list