[Tutor] OOP and Python.. a gentle remark

euoar euoar at yahoo.es
Wed Oct 25 11:46:10 CEST 2006


Asrarahmed Kadri escribió:
>  
>  
> Folks...
>  
> Please dont take it in a wrong sense. But I have a point to make 
> regarding OOP and the way it is implemented in Python.
>  
>  Why is it necessary to explicity use self argument in the class 
> functions ?? I feel the language/interpreter should figure out which 
> object has called the function? Isnt it ? (the use of 'self' keyword 
> really confuses me. and to make matter worse the variables can be 
> accessed from outside teh class. Isnt it a violation of the OOP 
> principle of ENCAPSULATION)
>  
> Also please let me know hwo can we declare PRIVATE VARIABLES in 
> Python...??
>  
> Regards,
> Asrarahmed
>  
> P.S. : I love Python. :)-
>
> -- 
> To HIM you shall return.
> ------------------------------------------------------------------------
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>   
That's something that I also don't understand, but I'm just a beginner 
in python, coming from java and C#, where this is not necessary. It 
seems to me quite annoying having to write this "self" each time, and I 
think it makes the code less readable. I have googled a little to see if 
there is an explanation to this particularity, with no sucess, so I will 
pay much attention to the answers here...

	
	
		
______________________________________________ 
LLama Gratis a cualquier PC del Mundo. 
Llamadas a fijos y móviles desde 1 céntimo por minuto. 
http://es.voice.yahoo.com


More information about the Tutor mailing list