Too many 'self' in python.That's a big flaw in this language.
Neil Cerutti
horpner at yahoo.com
Wed Jun 27 08:01:34 EDT 2007
On 2007-06-27, hide1713 at gmail.com <hide1713 at gmail.com> wrote:
> HI
> I'm currently using Python. I find that a instance variable must
> confined with self,
> for example:
> class a:
> def __init__(self):
> self.aa=10
> def bb(self):
> print self.aa # See .if in c++,I could use aa to change that
> variable
>
> That's a big inconvenience in coding ,especially when you have
> lot of variable If you method need 10 variables ,you have to
> type "self" for 10 times and that also makes your variable
> longer.
I recommend the discussion of this issue in the Python FAQ.
http://www.python.org/doc/faq/general/#why-must-self-be-used-explicitly-in-method-definitions-and-calls
> From My point,I think this only help python interpreter to
> deside where to look for. Is there anyone know's how to make
> the interpreter find instance name space first? Or any way to
> make programmer's life easier?
Try thinking of "self." as a notation that provides vital
information to you, the programmer.
--
Neil Cerutti
More information about the Python-list
mailing list