Re: Calling a method with a variable name

2009-11-04 Thread Simon Mullis
May I be the first to say "Doh!" Problem solved, many thanks to both Carsten and Diez! SM 2009/11/4 Carsten Haese : > Simon Mullis wrote: >> def main(): >>     stats_obj = Statistic() >>     name = re.sub("[^A-Za-z]", "", sys.argv[0]) >>     method = getattr(stats_obj, name, None) >>     if call

Re: Calling a method with a variable name

2009-11-04 Thread Carsten Haese
Simon Mullis wrote: > def main(): > stats_obj = Statistic() > name = re.sub("[^A-Za-z]", "", sys.argv[0]) > method = getattr(stats_obj, name, None) > if callable(method): > stats_obj.name() # else: > print "nope, not sure what yo

Re: Calling a method with a variable name

2009-11-04 Thread Diez B. Roggisch
Simon Mullis wrote: > Hi All, > > I'm collating a bunch of my utility scripts into one, creating a > single script to which I will symbolic link multiple times. This way > I only have to write code for error checking, output-formatting etc a > single time. > > So, I have > > ~/bin/foo -> ~/C