<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
> > 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>
> > 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>
> ><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>
> > 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>
> ><br>
><br>
> Would nesting the non-convenience Enum in a function or a class allow one<br>
> to pickle it?<br>
<br>
</div></div>Once PEP 3154 is implemented (Alexandre is on it :-)), nested classes<br>
should be picklable.</blockquote><div><br></div><div>Interesting, I did not know that.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> As for classes inside functions, it sounds quite<br>


impossible (how do you instantiate the function namespace without<br>
calling the function?).<br>
</blockquote><div><br></div><div>True.<br><br></div><div>Back to my question from before, though - do we have a real technical limitation of having something like inspect.what_module_am_i_now_in() that's supposed to work for all Python code?<br>

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