ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-dev
python-dev
[Python-Dev] Draft proposal: Implicit self in Python 3.0
by Jim Jewett other posts by this author
Jan 6 2006 11:28AM messages near this date
Re: [Python-Dev] Draft proposal: Implicit self in Python 3.0 | Re: [Python-Dev] Draft proposal: Implicit self in Python 3.0
Nick Coghlan wrote:

>     Eliminate the need for explicit class and self
>     slots in class and instance methods by
>     implicitly providing those slots on all functions.

>  How many positional arguments does the function
>  have if I retrieve it from the class, rather than from
>  an instance?

To keep things simple, it should have the same
number of positional arguments no matter how
you retrieve it -- think of self and cls as keyword
arguments that we currently write in an odd manner.

>     class Foo:
>         def __init__(x):         # 1: Implicit self
>             .x = x               # 2: Brief form of: self.x = x
>         def bar(a, b):           # 3: Two arguments...
>             print .x + a + b

>     f = Foo(10).bar              # We agree this accepts 2 arguments
>     f = Foo.bar                  # How many arguments does f accept?
>     f = Foo.__dict__["bar"]      # How many arguments does it accept now?

>  The answer to the first question *has* to be 3,
>  or we lose too much functionality

No, it should be 2.  If you use it as a staticmethod,
there isn't any problem.  If you really want a method
outside of its context, then pass self (or cls) as a keyword.

    f(4,5,self=Foo(10))

(I also think we could use class as the keyword, since
    class=expression
is different from
    class Name:
but that is a separate question.)

If you like having self at the front -- well, wasn't
the "keywords must be last" restriction likely to
go away even before python 3.0?

>  ... a Java or C++ background where
>  you can't manipulate functions and classes as
>  first-class objects - the idea that the instance
>  method signature could be written to describe
>  the signature of the unbound method returned
>  by "Foo.bar" rather than the bound method
>  returned by "Foo().bar" is an entirely foreign
>  concept.

I find it sort of strange that the signatures are
different in the first place.  I prefer the one
without boilerplate.

-jJ
_______________________________________________
Python-Dev mailing list
Python-Dev@[...].org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/python-dev-ml%40activestate.c
om
Thread:
Alexander Kozlovsky
Ralf W. Grosse-Kunstleve
Ian Bicking
Thomas Wouters
Tim Peters
Brett Cannon
Fredrik Lundh
Ralf W. Grosse-Kunstleve
Samuele Pedroni
Fredrik Lundh
Ralf W. Grosse-Kunstleve
Thomas Wouters
Ralf W. Grosse-Kunstleve
Phillip J. Eby
Thomas Wouters
Fredrik Lundh
Armin Rigo
Guido van Rossum
Ralf W. Grosse-Kunstleve
"Martin v. Löwis"
"Martin v. Löwis"
Kay Schluehr
Guido van Rossum
Thomas Wouters
Phillip J. Eby
"Martin v. Löwis"
Thomas Wouters
"Martin v. Löwis"
Thomas Wouters
Tim Peters
Ian Bicking
Thomas Wouters
Ian Bicking
Samuele Pedroni
Kay Schluehr
Alexander Kozlovsky
Jim Jewett
Fabien Schwob
Kay Schluehr
Nick Coghlan
Ian Bicking
"Martin v. Löwis"

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved