On Nov 8, 7:21*pm, pineapple <pineapple.l...@yahoo.comwrote:
On Nov 8, 12:24 pm, "Chris Rebert" <c...@rebertia.comwrote:
The code you gave works perfectly:
Weird! Doesn't work at all on my system (WinXP, Python 2.5).
Please post some of the actual code so that we can determine the problem.
Taking a guess, I'd suspect Blah and commands are in different modules
Nope, that was the actual code - in fact it was the whole program.
You haven't shown *ALL* of what you think you typed. Here's a copy/
paste from my console:
=== start ===
C:\junk>ver
Microsoft Windows XP [Version 5.1.2600]
C:\junk>python
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>class Blah(list):
.... pass
....
>>commands = {1: (lambda: Blah())}
commands
{1: <function <lambdaat 0x00B97E70>}
>>commands[1]
<function <lambdaat 0x00B97E70>
>>commands[1]()
[]
>>cx = {42:Blah}
cx[42]()
[]
>>>
Now, what results do you get?