Prototype OO

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Wed Apr 2 23:57:09 CEST 2008


En Wed, 02 Apr 2008 09:23:21 -0300, sam <sam at mas.pl> escribió:

> Gabriel Genellina 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?
>
> Yes. Funciton is always a piece of code (program) that does something.  
> There is
> no need for different syntax.

Guido has regretted lambda for a long time; it was scheduled for deletion  
on Python 3000 [2] but finally will stay [3].
Class methods and instance methods are not just standard functions;  
instance methods were plain functions before 2.2 and the Class object was  
in charge of doing the "self magic". Now the descriptor protocol provides  
far more possibilities.

> And you said that it is good to have these two types of syntax. It  
> sounds like:
> "it is good to have knife and scissors to cut the _same_ thing, because  
> they are
> not the same".

I didn't say that (note that you trimmed most attribution lines) but I  
like to have "short anonymous functions" altough the syntax might be  
different. Perhaps in Python 4000.

>> What are those programmers needs?
>
> Programmers need to protect name in a namespace. Name mangling is not  
> the best
> choice.

Why to "protect" names in a namespace? We are all adults here. Name  
mangling is a reasonable and simple way to avoid name conflicts in a  
shared namespace. I don't know whether it's the "best" way or not, but has  
worked fine for me for a long time.

[1] http://www.python.org/doc/essays/ppt/regrets/PythonRegrets.ppt  
(couldn't find easily an older reference, but there are)
[2] http://www.artima.com/weblogs/viewpost.jsp?thread=98196
[3] http://mail.python.org/pipermail/python-dev/2006-February/060415.html

-- 
Gabriel Genellina




More information about the Python-list mailing list