[IronPython] Partial classes

Ronnie Maor ronnie.maor at gmail.com
Fri Jun 13 15:53:51 CEST 2008


you can also add methods to an existing class like this:

class A(object):
    ...

def foo(self,x,y):
    ...

A.foo = foo

On Fri, Jun 13, 2008 at 3:22 PM, Michael Foord <fuzzyman at voidspace.org.uk>
wrote:

> Michael Stephens 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.
>>
>
> Emit them as one file per function. Then have one file that imports them
> all and constructs a dictionary mapping function name to imported function.
> You can turn it into a class by calling:
>
> new_class = type(name, (object,), dict_of_functions)
>
> type is the default metaclass, and responsible for creating new classes.
> Every function will be a method of the new class.
>
> Michael Foord
> http://www.ironpythoninaction.com/
>
>
>
>> 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 <mailto:falcon at uwyo.edu> or 89iroc at gmail.com <mailto:
>> 89iroc at gmail.com>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.ironpython.com
>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.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/20080613/f1b4b3bd/attachment.html>


More information about the Ironpython-users mailing list