<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, May 1, 2013 at 1:33 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="HOEnZb"><div class="h5">On Wed, 1 May 2013 13:05:53 -0700<br>
Eli Bendersky <<a href="mailto:eliben@gmail.com">eliben@gmail.com</a>> wrote:<br>
> On Wed, May 1, 2013 at 11:59 AM, Georg Brandl <<a href="mailto:g.brandl@gmx.net">g.brandl@gmx.net</a>> wrote:<br>
><br>
> > Am 01.05.2013 20:44, schrieb Antoine Pitrou:<br>
> > > On Wed, 01 May 2013 10:21:30 -0700<br>
> > > Ethan Furman <<a href="mailto:ethan@stoneleaf.us">ethan@stoneleaf.us</a>> wrote:<br>
> > >> We may not want to /completely/ disallow subclassing.  Consider:<br>
> > >><br>
> > >> --> class StrEnum(str, Enum):<br>
> > >> ...    '''string enums for Business Basic variable names'''<br>
> > >> ...<br>
> > >> --> class Vendors(StrEnum):<br>
> > >> EnumError: subclassing not allowed<br>
> > ><br>
> > > I don't see the point of disallowing subclassing. It sounds like<br>
> > > a pointless restriction.<br>
> > ><br>
> > > However, perhaps the constructor should forbid the returning of a base<br>
> > > type, e.g.:<br>
> > ><br>
> > > class Season(Enum):<br>
> > >     spring = 1<br>
> > ><br>
> > > class MySeason(Season):<br>
> > >     """I look nicer than Season"""<br>
> > ><br>
> > > MySeason('spring')<br>
> > > ...<br>
> > > ValueError: Season.spring is not a MySeason instance<br>
> > ><br>
> > > (what this means is perhaps the subclassing of non-empty enum classes<br>
> > > should be forbidden)<br>
> ><br>
> > That's exactly what's implemented in the ref435 code at the moment.<br>
> ><br>
> ><br>
> It can't be because __call__ is by-value lookup, not by-name lookup.<br>
<br>
</div></div>Ok, I've mixed up the example. But, still, since Season(1) should<br>
return the Season.spring singleton, I don't see any reasonable thing<br>
for MySeason(1) to return. Hence the request to raise an exception.<br></blockquote></div><br></div><div class="gmail_extra">What do you need MySeason for, though? IIUC, you don't ask to allow adding enum values in it, so it only leaves adding extra functionality (methods)? What are the use cases?<br>

<br></div><div class="gmail_extra">Eli<br><br><br><br><br></div><div class="gmail_extra"><br></div></div>