[Python-Dev] Re: PEP 318: Can't we all just get along?
Paul Morrow
pm_mon at yahoo.com
Thu Aug 19 23:06:23 CEST 2004
More information about the Python-Dev mailing list
Thu Aug 19 23:06:23 CEST 2004
- Previous message: [Python-Dev] Re: PEP 318: Can't we all just get along?
- Next message: [Python-Dev] PEP 318: Can't we all just get along?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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).
- Previous message: [Python-Dev] Re: PEP 318: Can't we all just get along?
- Next message: [Python-Dev] PEP 318: Can't we all just get along?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list