LoginSignup
1
2

More than 5 years have passed since last update.

Python3 > enum.auto() > ImportError: cannot import name 'auto' > Python 3.6から使用可能

Posted at
CentOS 6.8 (64bit)
Python 3.4.5

関連

enumって何だよ

エラー

enum_auto_180315.py
from enum import Enum, auto
class Youbi(Enum):
    MON = 1

print(Youbi.MON)
$ python3 enum_auto_180315.py 
Traceback (most recent call last):
  File "enum_auto_180315.py", line 1, in <module>
    from enum import Enum, auto
ImportError: cannot import name 'auto'

The auto is unique in py3.6 and don't contain in py3.5, how can I change the code to let it work?

enumのautoはPython 3.6から使えるようだ。

バージョン 3.6 で追加: Flag, IntFlag, auto

ideone.comのPython3は3.5なのでRuntime errorが出る。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2