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
Re: [Python-Dev] Draft proposal: Implicit self in Python 3.0
by Fabien Schwob other posts by this author
Jan 6 2006 4:17AM messages near this date
[Python-Dev] Draft proposal: Implicit self in Python 3.0 | Re: [Python-Dev] Draft proposal: Implicit self in Python 3.0
>  Example 1 (Python 2.x):
 >  -----------------------
 > 
 >      class Foo:
 >          def __init__(self, x):   # 1: Explicit 'self' argument
 >              self.x = x           # 2: 'self' must be used explicitly
 >          def bar(self, a, b):     # 3: There are three arguments...
 >              print self.x + a + b
 > 
 >      Foo(10).bar(20, 30)          # ...but only two explicit parameters
 >                                   #    is presented
 > 
 >  This document proposes to change this, as the next example shows:
 > 
 >  Example 2 (Python 3.0):
 >  -----------------------
 > 
 >      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
 > 
 >      Foo(10).bar(20, 30)          # ...and exactly two parameters

In my case, I think that the problem of _self_ is mainly in the method 
definition. It's a little "hard" to understand why you have to use 
myFunction(self, otherArgs) when you create a class method. But the use 
of self in the code of the method is a good thing because it allow you 
to clearly say that you are working on a class property. In my case, I 
would like to have the following syntax in Python 3.0 :

class Foo:
     def __init__(x):
	self.x = x
     def bar(a, b):
	print self.x + a + b

My 0.2â?¬ ;)

-- 
Fabien SCHWOB
_______________________________________________
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