The hardest problem in computer science...
Paul Moore
p.f.moore at gmail.com
Tue Jan 10 10:47:00 EST 2017
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
More information about the Python-list
mailing list