[NCLUG] Dumb Python Question
Evelyn Mitchell
efm at tummy.com
Tue Jul 30 13:33:39 MDT 2002
* On 2002-07-30 19:29 marciot <marciot at holly.colostate.edu> wrote:
> >===== Original Message From nclug at nclug.org =====
> >* On 2002-07-30 16:28 marciot <marciot at holly.colostate.edu> wrote:
> >> What's wrong with this line?
> >>
> >> popupMenu = Menu(self, tearoff=0)
> >> popupMenu.add_command(label="water", command=lambda: pass )
> >>
> >> Python whines about a syntax error right after "pass". I've tried to RTFM,
> but
> >
> >What package is "Menu" from?
>
> tkinter
>
> >
> >> there is so much documentation out there I can't find one that addresses my
> >> specific problem. There is such a thing as *too* much docs...
> >
> >pydoc2 'name of package containing Menu'
> >look for 'add_command'
>
> Actually, I think my problem relates to lambda functions, not to the Menu per
> se. For example, at the interactive prompt, I can type:
>
> a = lambda: sys.exit()
>
> But not:
>
> a = lambda: pass
>
> I wanted a lambda function that was equivalent to:
>
> def doNothing():
> pass
>
> Why doesn't python let me do that?
It looks from this:
http://www.python.org/tim_one/000050.html
that it is because lambda is expecting an expression, not a statement.
--
Regards, tummy.com, ltd
Evelyn Mitchell Linux Consulting since 1995
efm at tummy.com Senior System and Network Administrators
http://www.tummy.com/
More information about the NCLUG
mailing list