RE: c[:]()
- From: "Warren Stringer" <warren@xxxxxxxx>
- Date: Thu, 31 May 2007 07:49:22 -0700
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
.
- Follow-Ups:
- Re: c[:]()
- From: Douglas Woodrow
- Re: c[:]()
- References:
- "is" and ==
- From: BlueJ774
- RE: c[:]()
- From: Warren Stringer
- Re: c[:]()
- From: Dustan
- RE: c[:]()
- From: Warren Stringer
- Re: c[:]()
- From: Douglas Woodrow
- Re: c[:]()
- From: Douglas Woodrow
- "is" and ==
- Prev by Date: How to clean a module?
- Next by Date: Re: Upgrading a largish group of packages w/ distutils
- Previous by thread: Re: c[:]()
- Next by thread: Re: c[:]()
- Index(es):
Relevant Pages
|