Message343607
By changing one line of AutoNumber:
def __new__(cls):
to
def __new__(cls, *args):
Enums derived from AutoNumber can now support constructors that take named arguments; for example:
class Color(AutoNumber):
def __init__(self, pantone=None):
self.pantone = pantone or 'unknown'
class Swatch(Color):
AUBURN = ('3497')
SEA_GREEN = ('1246')
BLEACHED_CORAL = () # New color, no Pantone code yet!
Without the change, one gets the error:
TypeError: __new__() takes 1 positional argument but 2 were given
I attach runnable demonstration code. |
|
| Date |
User |
Action |
Args |
| 2019-05-27 06:03:00 | rrt | set | recipients:
+ rrt, docs@python |
| 2019-05-27 06:03:00 | rrt | set | messageid: <1558936980.63.0.0585299344314.issue37062@roundup.psfhosted.org> |
| 2019-05-27 06:03:00 | rrt | link | issue37062 messages |
| 2019-05-27 06:03:00 | rrt | create | |
|