finding name of instances created

Nick Coghlan ncoghlan at iinet.net.au
Mon Jan 24 06:41:18 EST 2005


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:

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.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at email.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.skystorm.net



More information about the Python-list mailing list