<div><div><div><br><div class="gmail_quote">On Wed, Jul 27, 2011 at 5:30 PM, Nick Coghlan <span dir="ltr"><<a href="mailto:ncoghlan@gmail.com">ncoghlan@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im"><br></div>
This recipe is pretty much the full extent of the proposal (perhaps<br>
with the automatic type generation I mention in the discussion<br>
section):<br>
<a href="http://code.activestate.com/recipes/577810-named-values/" target="_blank">http://code.activestate.com/recipes/577810-named-values/</a><br>
<div class="im"><br></div></blockquote></div><br></div></div></div><div><br></div><div>I like the NamedValue/namedvalue recipe. I prefer module constants like os.SEEK_END to nested names like os.Seek.End and this encourages that. If someone decides to change os module to:<br>

<div><br></div><div><span class="Apple-style-span">    SEEK_END = </span>namedvalue<span class="Apple-style-span">('SEEK_END', 2)</span></div><div><br></div><div>that won't break anything. For the simple enum case, a decorator could transform<div>

<br></div><div>    @enum</div><div>    class Color:</div><div>        red = 1</div><div>        green = 2</div><div><br></div><div>into:</div><div><br></div><div>    class Color:</div><div>        red = namedvalue('Color.red', 1)</div>

<div>        green = namedvalue('Color.green', 2)</div><div><br><div><font face="arial, helvetica, sans-serif">--- Bruce</font><div><font face="arial, helvetica, sans-serif">Follow me: <a href="http://www.twitter.com/Vroo" target="_blank">http://www.twitter.com/Vroo</a> <a href="http://www.vroospeak.com/" target="_blank">http://www.vroospeak.com</a></font></div>

</div></div></div></div>