[Chicago] Creating property() members programmatically

Martin Maney maney at two14.net
Sun Feb 8 16:26:17 CET 2009

On Sat, Feb 07, 2009 at 09:27:11AM -0600, Tim Gebhardt wrote:
> The best I've been able to do is use my data about the LAME parameters,
> output the Python code I need to a text file, and copy/paste that into my
> object's declaration.
> Does anyone know how I could create a bunch of property() items on an object
> based on a list of data?

How about instaed of cut'n'paste, you incorporate the generated code by
making it a base class (or classes - although I've done some work with
ctypes, I'm not sure I understand just what you're doing).

Alternately, perhaps you could implement the "properties" the
old-fashioned way, using __getattribute__ and __setattr__, with code
there that consults you hand-entered metadata to decide how to handle
each "property".  IIRC properties were introduced as a more convenient
way to handle the most common uses of these older methods.

"What's so funny?  That I'm sitting on a deserted beach at night,
nibbling at gourmet meals, and rereading every book I've ever loved?
Can you think of anything more worthwhile?"  -- Michael Flynn

More information about the Chicago mailing list