On Thu, 31 May 2007 07:49:22, Warren Stringer <[EMAIL PROTECTED]> wrote
>> >>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
[...]


>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()]()


Thanks Warren, I was merely pointing out the typing mistake you made in 
your first example.

And yes, your abstract names made it difficult to guess the intention of 
the original code.  With the meaningful names you've just provided, I 
can see immediately that you intended to write the 2nd working code 
alternative I suggested:

>> Oh no, I get it, you meant...
>> ,----
>> | c['b'] = b
>> | c[a()]()  #works!
>> `----

-- 
Doug Woodrow

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to