On Wed, May 1, 2013 at 11:59 AM, Georg Brandl <g.bra...@gmx.net> wrote:
> Am 01.05.2013 20:44, schrieb Antoine Pitrou: > > On Wed, 01 May 2013 10:21:30 -0700 > > Ethan Furman <et...@stoneleaf.us> wrote: > >> We may not want to /completely/ disallow subclassing. Consider: > >> > >> --> class StrEnum(str, Enum): > >> ... '''string enums for Business Basic variable names''' > >> ... > >> --> class Vendors(StrEnum): > >> EnumError: subclassing not allowed > > > > I don't see the point of disallowing subclassing. It sounds like > > a pointless restriction. > > > > However, perhaps the constructor should forbid the returning of a base > > type, e.g.: > > > > class Season(Enum): > > spring = 1 > > > > class MySeason(Season): > > """I look nicer than Season""" > > > > MySeason('spring') > > ... > > ValueError: Season.spring is not a MySeason instance > > > > (what this means is perhaps the subclassing of non-empty enum classes > > should be forbidden) > > That's exactly what's implemented in the ref435 code at the moment. > > It can't be because __call__ is by-value lookup, not by-name lookup. By-name lookup is Season.spring or getattr(Season, 'spring') Eli
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com