Hello Chipy,<br><br>Does anyone know of a way to create property() members on an object programmatically? Anything I've Googled with "property" and "programmatically" doesn't really come up with what I'm looking for.<br>
<br>Here's my use case:<br><br>I'm creating a ctypes wrapper for the LAME MP3 library. There are quite a few parameters that someone can set when encoding an MP3, such as the bitrate, number of audio channels, high pass frequency, blah, blah, blah. There's about 70. The issue is that there's 3 places in my wrapper where I have to declare them: once in the global LAME state object, once in setting up the argument types and return types of the LAME getter/setter functions, and once in my high level Python "Encoder" object.<br>
<br>So to make things easy and less error prone I declared a list of the parameters and their types so I could reuse the data I hand-typed in about these properties. I also have a small dictionary of overrides for parameters that aren't gettable or settable or that need to be handled with special circumstances. This worked fine for my first 2 places where I needed the data, but I'm struggling to get it to work for the 3rd part, my high-level Encoder object.<br>
<br>I need to be able to create a property() on my Encoder object because setting a LAME parameter on an MP3 stream actually needs to call the LAME library, and if the return value's not good then I need to throw an exception. <br>
<br>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.<br><br>Does anyone know how I could create a bunch of property() items on an object based on a list of data?<br>
<br>Thanks,<br><br>-Tim Gebhardt<br><a href="mailto:tim@gebhardtcomputing.com">tim@gebhardtcomputing.com</a><br>