Re: [Tutor] Dict of function calls

2010-09-23 Thread Steven D'Aprano
On Fri, 24 Sep 2010 01:45:29 am you wrote: > > Oh, and (4)... in Python circles, it's traditional but not > > compulsory to use metasyntactic variables named after Monty Python > > sketches rather than foo and bar. So spam, ham, eggs, parrot (dead > > or otherwise), names of cheeses, aardvark..., a

Re: [Tutor] Dict of function calls

2010-09-23 Thread Pete
> Oh, and (4)... in Python circles, it's traditional but not compulsory > to use metasyntactic variables named after Monty Python sketches > rather than foo and bar. So spam, ham, eggs, parrot (dead or > otherwise), names of cheeses, aardvark..., although there is no > standard order. Hm, some

Re: [Tutor] Dict of function calls

2010-09-22 Thread Steven D'Aprano
On Thu, 23 Sep 2010 09:21:27 am Pete wrote: > > (3) There's no need to keep the instances floating around as > > independent names, unless you need direct access to them. > > > > Putting these together, we get: > > > > dispatch_table = { 'foo': foo().do, 'bar': bar().do } [...] > I see. And are th

Re: [Tutor] Dict of function calls

2010-09-22 Thread Pete
On 2010-09-22, at 5:50 PM, Steven D'Aprano wrote: > On Thu, 23 Sep 2010 06:07:21 am Pete wrote: >> For a plugin mechanism, I'm populating a dict with calls to the >> implemented plugins. > [...] >> Now I get that I need to instantiate foo and bar first before I can >> refer to them in the dict. >

Re: [Tutor] Dict of function calls

2010-09-22 Thread Steven D'Aprano
On Thu, 23 Sep 2010 06:07:21 am Pete wrote: > For a plugin mechanism, I'm populating a dict with calls to the > implemented plugins. [...] > Now I get that I need to instantiate foo and bar first before I can > refer to them in the dict. > > so something like > > foo_instance = foo() > bar_instance