Function lookup using a directory.
johann at physics.berkeley.edu
Tue Jun 19 18:53:04 CEST 2001
andy pevy writes:
> The killer was the actual code to call the looked up class :-
> h = command_table[command]
> print command+' not found'
> It seems that you have to manually pass in the 'self' parameter
> when calling functions this way.
1. That last line should be "h().run()" to be idiomatic. First create
the instance, then run the "run" method.
2. Why are you using classes at all? If things are really as simple
as you make it seem, just use functions.
Johann Hibschman johann at physics.berkeley.edu
More information about the Python-list