Message273154
# Just wait until I put the keys to the time machine in their usual place... :-)
Ok, while we're talking about whether declarative style is a good idea, Python has already got the initial seed of that style. With Guido's blessing! PEP 526 enables us to mix declarative and imperative style in "ordinary" code, so we can write
@Enum
class Color:
green: member
yellow: member
without any additional syntax. I think it satisfies everyone: there are no parentheses, and there are no assignments. [_And_ there is no misleading analogy with existing syntax, because this is a new syntax.:] There are just declarations, and the decorator instantiates them.
Decorator is needed because formally we need to exclude the type checking semantics, and the only official way currently is through a decorator. But in fact we can use the forward references to _actually_ annotate the members with their real type:
class Color(Enum):
green: 'Color'
yellow: 'Color'
And once the forward references get a nicer syntax, and the unpacking issues are solved, we'll be able to write
class Color(Enum):
green, yellow: Color
And I think finally everyone will be happy. :-) |
|
Date |
User |
Action |
Args |
2016-08-19 19:33:59 | veky | set | recipients:
+ veky, barry, rhettinger, vstinner, eli.bendersky, ethan.furman, python-dev, abarry, John Hagen, David Hagen, kennethreitz |
2016-08-19 19:33:58 | veky | set | messageid: <1471635238.99.0.083343639225.issue26988@psf.upfronthosting.co.za> |
2016-08-19 19:33:58 | veky | link | issue26988 messages |
2016-08-19 19:33:58 | veky | create | |
|