Alan G wrote: >> 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.
I am playing with building a facility that accepts equations or expressions that are parsed and solved. I hope to use this with genetic algorithms that would create mostly useless expressions, but that over time might become better. If I was doing it for users building expressions, I'd probably do a javascript kind of approach for assembling expressions from lists. Your point is well taken, because I'm often awed at the amazing ly stupid errors that I make when I'm typing. Rest assured, I don't know 20 languages, computer or otherwise. I know that I used some sort of thing like that in the 80's with Revelation, a database/language derived from Pick. (That one is probably a little obscure, it may not be on your list of 20). I also think you can do that in Perl, but bear in mind I know less about Perl than I do Python. ds _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor