<br><br><div class="gmail_quote">On 25 July 2011 01:33, Guido van Rossum <span dir="ltr"><<a href="mailto:guido@python.org">guido@python.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
On Sun, Jul 24, 2011 at 3:47 PM, Nick Coghlan <<a href="mailto:ncoghlan@gmail.com">ncoghlan@gmail.com</a>> wrote:<br>
> We've actually been down the 'namespace object' road years ago (Steve<br>
> Bethard even wrote a proto-PEP IIRC) and it suffered the same fate as<br>
> most enum PEPs: everyone has slightly different ideas on what should<br>
> be supported, so you end up being faced with one of two options:<br>
> 1. Ignore some of the use cases (so some users still have to do their own thing)<br>
> 2. Support all of the use cases by increasing the API complexity (so<br>
> many users will still do their own thing instead of learning the new<br>
> API)<br>
<br>
For enums, I think we should just pick a solution. I'm in favor of<br>
Barry Warsaw's version, flufl.enum.<br></blockquote><div><br>I generally like the flufl.enum API. There are two things it doesn't do.<br><br>For new apis it is *usually* possible to just use strings rather than integers - and have your library do the mapping if an underlying api takes integers. For existing ones, for example many parts of the python standard library, we couldn't replace the integer values with enums without a lot of effort.<br>
<br>If the flufl enums subclassed integer then replacing most of the existing constants in the standard library would be trivially easy (so we'd have a built-in use case).<br>e<br>
The second use case, where you really do want to use integers rather 
than strings, is where you have flag constants that you "or" together. 
For example in the standard library we have these in r, gzip, msilib, some in xml.dom.NodeFilter, plus a bunch of others.<br><br>It would be nice to add support for or'ing of enums whilst retaining a nice repr.<br><br>
I did collect a whole lot of emails from a thread last year and was hoping to put a pep together. I'd support flufl.enum - but it would be better if it was extended so we could use it in the standard library.<br><br>All the best,<br>
<br>Michael Foord<br><br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<font color="#888888"><br>
--<br>
--Guido van Rossum (<a href="http://python.org/%7Eguido" target="_blank">python.org/~guido</a>)<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-ideas" target="_blank">http://mail.python.org/mailman/listinfo/python-ideas</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br><pre cols="72"><a href="http://www.voidspace.org.uk/" target="_blank">http://www.voidspace.org.uk/</a><br><br>May you do good and not evil<br>May you find forgiveness for yourself and forgive others<br>
May you share freely, never taking more than you give.<br>-- the sqlite blessing <a href="http://www.sqlite.org/different.html" target="_blank">http://www.sqlite.org/different.html</a></pre>
<br>