[Python-ideas] Conventions for function annotations
Nick Coghlan
ncoghlan at gmail.com
Sun Dec 2 12:43:34 CET 2012
More information about the Python-ideas mailing list
Sun Dec 2 12:43:34 CET 2012
- Previous message: [Python-ideas] Conventions for function annotations
- Next message: [Python-ideas] Conventions for function annotations
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sun, Dec 2, 2012 at 8:12 PM, Robert McGibbon <rmcgibbo at gmail.com> wrote: > Nick, > > Thanks! You make a very convincing argument. > > Especially if this represents the collective recommendation of the python > core development team on the proper conventions surrounding the use of > function annotations, I would encourage you guys to perhaps make it more > widely known (blogs, etc). As python 3.x adoption continues to move > forward, this type of thing could become an issue if shmucks like me start > using the annotation feature more widely. > Last time it came up, the collective opinion on python-dev was still to leave PEP 8 officially neutral on the topic so that people could experiment more freely with annotations and the community could help figure out what worked well and what didn't. Admittedly this was long enough ago that I don't remember the details, just the obvious consequence that PEP 8 remains largely silent on the matter, aside from declaring that function annotations are off-limits for standard library modules: "The Python standard library will not use function annotations as that would result in a premature commitment to a particular annotation style. Instead, the annotations are left for users to discover and experiment with useful annotation styles." Obviously, I'm personally rather less open-minded on the topic of *composition* in particular, as that's a feature I'm firmly convinced should be left in the hands of ordinary decorator usage. I believe trying to contort annotations to handle that cause is almost certain to result in something less readable than the already possible decorator equivalent. However, the flip-side of the argument is that if we assume my opinion is correct and document it as an official recommendation in PEP 8, then many people won't even *try* to come up with good approaches to composition for function annotations. Maybe there *is* an elegant, natural solution out there that's superior to using explicit calls to decorator factories for the cases that involve composition. If PEP 8 declares "just use decorator factories for cases involving composition, and always design your APIs with a non-annotation based fallback for such cases", would we be inadvertently shutting down at least some of the very experimentation we intended to allow? After all, while I don't think the composition proposal in this thread reached the bar of being more readable than just composing decorator factories to handle more complex cases, I *do* think it is quite a decent attempt. Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-ideas/attachments/20121202/def92399/attachment.html>
- Previous message: [Python-ideas] Conventions for function annotations
- Next message: [Python-ideas] Conventions for function annotations
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list