On Tuesday, 10 January 2017 15:47:20 UTC, Paul  Moore  wrote:
> On Saturday, 7 January 2017 19:14:43 UTC, Ethan Furman  wrote:
> > Ya know, that looks an /awful/ lot like a collection!  Maybe even an Enum?  
> > ;)
> > 
> > -- 8< -------------------------------------------------------
> > from aenum import Enum   # note the 'a' before the 'enum'  :)
> > 
> > class Theme(Enum, init='v vr llc'):
> >      DEFAULT = "│  ", "├─ ", "└─ "
> >      BOLD = "┃  ", "┣━ ", "┗━ "
> >      ASCII = "|  ", "|- ", "+- "
> > 
> > def draw_tree(tree, theme=Theme.DEFAULT):
> >      print(theme.v)
> >      print(theme.vr)
> >      print(theme.v)
> >      print(theme.llc)
> > 
> > draw_tree(None)
> 
> I noted the "a" before enum :-)
> 
> Is the implication that this form (a sort of combined namedtuple/enum) 
> *isn't* possible with the stdlib enum? But rather that it's specific to your 
> aenum module? I don't see any documentation for the "init" parameter in 
> either version, so I'm a little puzzled.
> 
> The capability seems neat, although (as is probably obvious) the way you 
> declare it seems a little confusing to me.
> 
> Paul

After a bit more digging I found 
https://docs.python.org/3.6/library/enum.html#planet which looks like a 
stdlib-supported way of doing the same sort of thing. I assume init is an aenum 
convenience argument to do the same?

Anyway, it's a neat feature - I'd not really looked beyond the surface of the 
new enum module, looks like I missed some good stuff :-)

Paul
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to