Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I personally use enums more than I declare them, so I don't mind a little bit of namedtuple-like repetitive syntax. I'm already used to namedtuple, so I don't see anything wrong with reusing that syntax for enum. It's Python, not a brand-new programming language.

I will admit I kind of like Java's syntax for enums because it makes it very clear what exactly an enum is: a class with a bounded set of instances:

  enum Month {
    JANUARY(31, "Jan"),
    FEBRUARY(28, "Feb"),
    MARCH(31, "Mar"), 
    ...;

    Month(int days, String abbreviation) { ... }
  }
(But honestly, Java enums have a number of annoyances and feel very "tacked on" like generics do.)


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: