On Thu, Nov 27, 2014 at 2:14 AM, Mark Summerfield <l...@qtrac.plus.com> wrote:
> I only mentioned it since I noticed it. I actually use Python 3 so it isn't a 
> problem for me, but sometimes I have to teach Python 2.7 and I wanted to 
> cover enum because it is so much nicer and easier to debug than FOO = 1 etc.
>
> However, the problem is that enum's function API doesn't play nicely with 
> unicode literals. One solution is to use the class API instead:
>
>
> from __future__ import print_function
> from __future__ import unicode_literals
> import enum
> print(enum.version)
> class A(enum.Enum):
>    b = 1
>    c = 2
> print(A.b, A.c)

Yeah, because now "class A" is not a literal, and is therefore not
affected by the unicode_literals directive. But I think that notation
looks just fine anyway, so that would probably be the cleanest
solution.

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

Reply via email to