<br><div><div class="gmail_quote">On Sat, Feb 7, 2009 at 10:57 AM, Brantley Harris <span dir="ltr">&lt;<a href="mailto:deadwisdom@gmail.com">deadwisdom@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
So it&#39;s easy enough to declare properties on classes, but rather<br>
difficult to do so on objects themselves (I&#39;m not even sure it&#39;s<br>
possible, well not good form anyhow.)<br>
<br>
So you have a few options. &nbsp;One is to subclass your Encoder with an<br>
intermediate class, and then add properties, dynamically to it:<br>
 &nbsp;class LameEncoder(Encoder):<br>
 &nbsp; &nbsp;@classmethod<br>
 &nbsp; &nbsp;def add_property(cls, attr, default):<br>
 &nbsp; &nbsp; &nbsp;def setter(self, v):<br>
 &nbsp; &nbsp; &nbsp; &nbsp;setattr(self, &#39;_%s&#39; % attr, v)<br>
 &nbsp; &nbsp; &nbsp;def getter(self):<br>
 &nbsp; &nbsp; &nbsp; &nbsp;return getattr(self, &#39;_%s&#39; % attr, default)<br>
 &nbsp; &nbsp; &nbsp;setatter(cls, attr, property(gettter, setter))<br>
<br>
 &nbsp;for attr, default in PARAMETER_LIST:<br>
 &nbsp; &nbsp;LameEncoder.add_property(atter, default)<br></blockquote></div><br></div><div>I went with the first method you suggested and it worked perfectly. &nbsp;Thanks!</div><div><br></div><div>-Tim Gebhardt</div><div><a href="mailto:tim@gebhardtcomputing.com">tim@gebhardtcomputing.com</a></div>
<div><br></div>