[Tutor] call a def/class by reference

Alan G alan.gauld at freenet.co.uk
Thu Sep 29 23:26:19 CEST 2005


> I'm actually pretty surprised that there isn't a built-in facility 
> with
> Python for referencing functions like this.

I'm not. In fact its pretty unusual in any language to try to map
from function name to function directly. Dictionaries are the
universal solution for this, I can only think of a handful(4?)
languages that I've used (Out of 20 plus) that can do
string -> function mapping directly.

Its not usually a very useful thing to do - how would the
typical user know what the function names were? Either the
user has access to the code or the code presents the names
to the user(as strings) in which case a mapping has to
exist somewhere already.

I'm curious as to how you are addressing those issues?
Is this something that only developers will be using?
How will the user know what names are possible?

Alan G. 



More information about the Tutor mailing list