[IronPython] Partial classes

Curt Hagenlocher curt at hagenlocher.org
Fri Jun 13 05:04:25 CEST 2008

The Python language doesn't support partial classes, but you can probably
achieve something similar by using multiple inheritance.  That is, put each
function into a separate class and then create an aggregate class that
derives from each of them.

>>> class A(object):
...     def test1(self):
...             print 'test1'
>>> class B(object):
...     def test2(self):
...             print 'test2'
>>> class C(A, B):
...     def __init__(self):
...             self.test1()
...             self.test2()
>>> C()
<C object at 0x000000000000002B>
There are generally certain "gotchas" to look out for with multiple
inheritance, but provided that you're not using the same method names across
multiple base classes -- including special names like __init__ -- you
shouldn't run into any of them.

On Thu, Jun 12, 2008 at 7:29 PM, Michael Stephens <falcon at uwyo.edu> wrote:

> Our company has a scripting/macro system.  Functions are stored in a
> database and at runtime we generate python classes.  For a form we have
> multiple functions declared.  We want to use IronPython studio to emit the
> python classes to a file to be debugged.  Is it possible to build a partial
> class so that we can have one file per function.
> file function324.py
> partial class Form76:
>  def function324.py
> file function325.py
> partial class Form76
>  def function324.py
> file base325.py
>  #do not edit anything in this file! changes will not be saved!
> Michael Stephens
> Electrical Engineering Graduate Student
> University of Wyoming
> falcon at uwyo.edu or 89iroc at gmail.com
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20080612/1aa2b5d1/attachment.html>

More information about the Ironpython-users mailing list