En Mon, 31 Mar 2008 07:59:13 -0300, sam <[EMAIL PROTECTED]> escribió:

> Steve Holden napisał(a):
>
>>> 1. You have different syntax for named and unnamed (lambdas)
>>> functions. Functions and methods are different things in Python even
>>> if they have same syntax. But all these are still a pieces of code
>>> that you use repeatedly to make some task.
>>>
>> A knife and scissors are both used to cut things, but that doesn't mean
>> they are the same.
>
> Well -- sometimes you have to use many, many types of scissors.

I don't get the point - weren't you criticizing Python for having many  
different kind of functions?

>> The desire to provide information hiding is fundamentally against the
>> Python philosophy, which basically says that attribute values are
>> exposed for all to see. This avoids the nonsense of having to provide
>> setter and getter methods which Java imposes on the programmer.
>
> This philosophy is great and makes Python such a good language. But you  
> can't go
> beyond what programmers need. If you do so, then you will have to  
> implement
> tricks as __id.

The __id "trick" is not for hidding instance attributes, but to avoid name  
collisions. Unlike other languages, all instance attributes share a single  
namespace, you can't qualify a reference to say "the foo attribute from  
this base class, not this other foo": it is always "the foo attribute" no  
matter inside which class it was assigned.
The __ prefix creates mangled names so __foo used inside a certain class  
is a different attribute name than __foo outside that class. It is not  
used to "hide" the attribute, the rules for the mangled name are very easy  
to emulate.

What are those programmers needs?

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to