<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, May 2, 2013 at 1:22 PM, Antoine Pitrou <span dir="ltr"><<a href="mailto:solipsis@pitrou.net" target="_blank">solipsis@pitrou.net</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">On Thu, 2 May 2013 13:15:00 -0700<br>
Eli Bendersky <<a href="mailto:eliben@gmail.com">eliben@gmail.com</a>> wrote:<br>
> > Two things that were suggested in private:<br>
> ><br>
> > 1) ask users to pass the module name to the convenience function<br>
> > explicitly (i.e. pass "seasonmodule.Season" instead of "Season" as the<br>
> > class "name"). Guido doesn't like it :-)<br>
> ><br>
> > 2) dicth the "convenience function" and replace it with a regular<br>
> > class-based syntax. Ethan doesn't like it :-)<br>
> ><br>
><br>
> Re (2), we already have the hack in stdlib in namedtuple, so not allowing<br>
> it for an enum is a step backwards.<br>
<br>
</div>That's a fallacy. There is no step backwards if you adopt a class-based<br>
syntax, which is just as convenient as the proposed "convenience<br>
function". I have a hard time understanding that calling a function to<br>
declare a class is suddenly considered "convenient".<br>
<div class="im"><br>
> If<br>
> sys._getframe(1).f_globals['__name__'] feels hackish, maybe it can be<br>
> shortened to a convenience function the stdlib provides?<br>
<br>
</div>It's not the notation which is hackish, it's the fact that you are<br>
inspecting the frame stack in the hope of getting the right information.<br>
<br>
What if someone wants to write another convenience function that wraps<br>
your convenience function? What if your code is executing from some<br>
kind of step-by-step debugger which inserts an additional frame in the<br>
call stack? What if someone wants the enum to be nested inside another<br>
class (rather than reside at the module top-level)?<br>
</blockquote><br><div>Would nesting the non-convenience Enum in a function or a class allow one to pickle it? I think programmers who want their libraries to be pickle-able already have to be aware of some restrictions about what can and cannot be pickled.<br>

<br>Eli<br><br></div><div> </div></div><br></div></div>