Op 2005-01-24, Nick Coghlan schreef <[EMAIL PROTECTED]>:
> Steven Bethard wrote:
>> That is, you can just keep track of all the names of a Robot in the 
>> Robot object.  In the simple case, where there's only one name, you can 
>> display it as such.  In the more complicated case, where there's some 
>> aliasing, you can display the multiple aliases.  This means you don't 
>> have to teach about aliasing right off the bat, but if a student 
>> accidentally discovers it on their own, the machinery's there to explain 
>> it...
>
> Incidentally, this discussion made me realise the real reason why using a 
> lambda 
> to create a named function is evil:

It is not a named function, it is just a lamda that is assigned to a
name.
>
> Py> def f(): pass
> ...
> Py> f.func_name
> 'f'
> Py> f = lambda: None
> Py> f.func_name
> '<lambda>'
>
> I think I've heard that explanation before, but it never really clicked.

I just don't see what is so evil about it.

Why is it so trouble some that a function wouldn't have a name, while
most objects don't have a name. Why is it a problem doing something
like:

   f = lambda: None

But isn't it a problem doing something like

   v = None.


Why don't we demand something like

   Py> assign v: None
   Py> v.obj_name
   'v'

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

Reply via email to