> Darn -- it WOULD be better in some cases if one could ONLY call > a method on the class, NOT on an instance when the call would in > any case ignore the instance. Calling dict.fromkeys(L3) is wonderful, > the problem is that you can also call it on a dict instance, and THAT > gets confusing. Similarly, calling list.sorted(iterable) is wonderful, > but calling it on a list instance that gets ignored, L1.sorted(iterable), > could perhaps be confusing. Then why don't you use a custom descriptor which raises an exception when an instance is passed in? Like: def __get__(self, obj, cls): if obj is None: return new.instancemethod(self.classmeth, cls) else: raise TypeError, \ "Calling %s on instance %s ignores instance" % \ (self.classmeth, obj) -- Christian Tanzer http://www.c-tanzer.at/
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