On Wed, Feb 25, 2004 at 11:33:40PM +0000, Mark Russell wrote: [...] > > It would be interesting to show > > def foo(self) [classmethod]: > > to a relative python beginner and ask them the guess at the meaning. My > hunch is that they would assume that "[classmethod]" modifies the > meaning of the function defintion in some way. The curious could then > look up classmethod in the manual, where they would presumably find a > note about the [] syntax. Exactly -- this is why a keyword isn't need, the decorator is the "keyword". Where Java people need to lookup "static" in their language manual, Python people will lookup "staticmethod" in the library reference. The documentation for staticmethod would presumably mention that it's a "function decorator", and link to the appropriate docs, and maybe even give an example. And regardless of "[]" vs. "as", I would expect that a confused user could read the language reference docs for function declarations (i.e. there's already a keyword for them to lookup: def!) to find out what the annotation syntax means. So, as far as I can see, "[]" vs. "as" will make no practical difference to the ease-of-documentation-lookup, so my preference is to go with the syntax that looks subjectively better to my eyes -- which is []. I don't mind "as" either, though. -Andrew.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4