c[:]()
Warren Stringer
warren at muse.com
Thu May 31 10:49:22 EDT 2007
Hey Douglas,
Perhaps I was being too abstract? Here goes:
,-------------------------------
| def selector():
| ...
| return funcKey #get down get down
|
| def func():
| ...
| funcSwitch = {}
| funcSwitch[funcKey] = func
| ...
| funcSwitch[selector()]()
even more interesting is a
,----------------------------------------
| def judge(contestants):
| for contestant in contestants:
| ...
| if answersQuestionToSatisfaction:
| yield semiFinalist
|
| beauty[judge(beauty)]()
hmmmm, I suppost you could just call
judge(beauty)
and have the judge call the contestant personally.
But that may be *too* personal. Moreover, what about
the other judges? Wouldn't it be best to simply state:
beauty[judges[:](beauty)].thankyouForThisOpportunity()
This allows each judge to choose differently while all
the contestants behave consistently. It kind of like an
off the cuff decorator for generators, where
beauty[...].decoration()
Maybe there's a better way of doing this? I don't know.
> >>
> >>def a(): return 'b'
> >>def b(): print 'polly! wakey wakey'
> >>c = {}
> >>c['a'] = b
> >>c[a()]() #works!
> >
> >
> >(typo correction for other easily-confused newbies like myself)
> >
> >I think you mean
> >,----
> >| c['a']() #works!
> >`----
> >
>
> Oh no, I get it, you meant...
> ,----
> | c['b'] = b
> | c[a()]() #works!
> `----
>
> ...or was it?:-
> ,----
> | def a(): return 'a'
> `----
>
> --
> Doug Woodrow
>
> --
> http://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list