[Python-Dev] a Constant addition to enum (original) (raw)
Ethan Furman ethan at stoneleaf.us
Tue Aug 6 22:42:18 CEST 2013
- Previous message: [Python-Dev] Our failure at handling GSoC students
- Next message: [Python-Dev] a Constant addition to enum
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
A question came up on stackoverflow asking about the Planet example and the need to have the constant G defined in the method instead of at the class level:
http://stackoverflow.com/q/17911188/208880
Since methods and descriptors are immune to enumeration my proposed solution created a Constant descriptor that could be used to keep class level constants at the class level. It's not complex, only about 7 lines. Should we have something like that included in the enum module?
If we do include something like that, should it be constant, or should it be more like property? (The important differences from property being that class access still returns the value, not the property itself, and setting the class-level value changes the value but doesn't replace the property.)
--
Ethan
- Previous message: [Python-Dev] Our failure at handling GSoC students
- Next message: [Python-Dev] a Constant addition to enum
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]