Vladimir> So far, I have the impression that all I get (if I get Vladimir> anything at all -- see above) is "conveniency" from Gordon, Vladimir> which is nothing else but laziness about creating instances. No, you get function metadata. Barry's original reason for creating the patch was that the only writable attribute for functions or methods is the doc string. Multiple people are using it now to mean different things, and this leads to problems when those different uses clash. I submit that if I have to wrap methods (not functions) in classes and instantiate them to avoid being "lazy", then my code is going to look pretty horrible after applying this more than once or twice. Both Zope and John Aycock's system (SPARK?) demonstrate the usefulness of being able to attach metadata to functions and methods. All Barry is suggesting is that Python support that capability better. Finally, it's not clear to my feeble brain just how I would go about instantiating a method to get this capability today. Suppose I have class Spam: def eggs(self, a): return a and I want to attach an attribute to Spam.eggs that tells me if it is public/private in the Zope sense. Zope requires you to add a doc string to a method to declare that it's public: class Spam: def eggs(self, a): "doc" return a Fine, except that effectively prevents you from adding doc strings to your "private" methods as Greg Stein pointed out. Barry's proposal would allow the Spam.eggs author to attach an attribute to it: class Spam: def eggs(self, a): "doc" return a eggs.__zope_access__ = "private" I think the solution you're proposing is class Spam: class EggsMethod: def __call__(self, a): "doc" return a __zope_access__ = "private" eggs = EggsMethod() This seems to work, but also seems like a lot of extra baggage (and a performance hit to boot) to arrive at what seems like a very simple concept. -- Skip Montanaro | http://www.mojam.com/ skip@mojam.com | http://www.musi-cal.com/
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