Vedran Čačić added the comment:
# 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. :-)
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue26988>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com