Very simple - please help

John Machin sjmachin at lexicon.net
Sat Nov 8 06:59:35 EST 2008


On Nov 8, 7:21 pm, pineapple <pineapple.l... at yahoo.com> wrote:
> On Nov 8, 12:24 pm, "Chris Rebert" <c... at rebertia.com> wrote:
>
> > 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 <lambda> at 0x00B97E70>}
>>> commands[1]
<function <lambda> at 0x00B97E70>
>>> commands[1]()
[]
>>> cx = {42:Blah}
>>> cx[42]()
[]
>>>

Now, what results do you get?



More information about the Python-list mailing list