Bob Ippolito wrote: > > On Aug 19, 2004, at 3:30 PM, Paul Morrow wrote: > >> James Y Knight wrote: >> >>> On Aug 19, 2004, at 7:45 AM, Paul Morrow wrote: >>> >>>> The vast majority of instance methods I've seen all use 'self' as >>>> the first parameter. Likewise, most class methods use 'cls' or >>>> 'klass' as their first parameter. If we exploit these conventions, >>>> we end up with a simple, clear, obvious mechanism for denoting (this >>>> aspect of) a method's type. >>>> >>>> class Foo(Object): >>>> def m1(self, a, b): # this is an instance method of Foo >>>> pass >>>> >>>> def m2(cls, a, b): # this is a class method of Foo >>>> pass >>>> >>>> def m3(a, b): # this is a static method of Foo >>>> pass >>>> >>>> A special Object (capital 'O') class could work this magic so that >>>> old code didn't break. >>>> >>>> I know that this is odd. But then so are most of the great things >>>> about Python. >>> >>> You can do that today. See also >>> http://www.python.org/pycon/dc2004/papers/48/conveniencytypes.py >> >> >> Aha! Thanks! > > > Whatever happened to explicit is better than implicit? ;) > I've often wondered about that principle. For example, wouldn't static typing (actual declarations, as in Java) be more explicit than dynamic typing? Either way, it seems that if dynamic method typing (static|class|instance) was enabled for a class, then def m2(cls, a, b): pass would be every bit as explicit (a means of specifying that m2 is a class method) as x = [] (is of specifying that x is (well, contains) a list).
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