Python enum implementation

This question already has an answer here:

  • How can I represent an 'Enum' in Python? 43 answers

  • You should never have to create an instance of an enum; they're all accessed directly from the class, and you can just assign them to variables as you like:

    a = CBarReference.ThisBar
    b = CBarReference.NextBar
    c = CBarReference.Undefined
    d = CBarReference.ThisBar
    assert(a == d)
    assert(b != a)
    assert(b != c)
    
    链接地址: http://www.djcxy.com/p/91752.html

    上一篇: python是否支持枚举类型?

    下一篇: Python枚举实现