4 ms·
> Thanks, checking out PEP 3107 now. I've always seen annotations done with the @annotation syntax like the Python 2 snippet has. The @ syntax is for decorator
by algorias 17y ago
> Thanks, checking out PEP 3107 now. I've always seen annotations done with the @annotation syntax like the Python 2 snippet has.
The @ syntax is for decorators. Different beast altogether.
- steveklabnik 17y agoAh. So, Python uses the Java annotation syntax for decorators? Hm. One more thing I'll have to look into when I get the time.
- rbanffy 17y agoActually, I think Java uses Python decoration syntax for annotations, but I have been wrong before.
- pmiller2 17y agoI'm pretty sure Python picked it up after Java did. But, I don't think it's a case of imitation; it's just that the glyph '@' happened not to have syntactic meaning attached to it and it looks okay.
- blasdel 17y agoNo, they're exactly the same beast! I've used decorators to add attributes to function objects in several projects in the past -- you don't have to wrap the original.