Makeing a constant ??

Matthias Barmeier barmeier at barmeier.com
Fri Mar 17 11:03:49 EST 2000


On 17 Mar 2000 13:54:39 GMT, froydnj at rose-hulman.edu (Nathan Froyd)
wrote:

>Matthias Barmeier wrote:
>>This expression looks like this:
>>	widget.bind(itemName, lambda e, cb=self.driveEvent: 
>>			cb(e,itemName))
>>
>>The second itemName in this expression is my problem.
>>When the event is fired I always get the message that itemName is
>>unknown.
>
>It's not so much that you need a "constant" variable (I have no idea what
>you're taking about here), but that the lambda expression can't see
>`itemName'. I believe this question is answered in the FAQ, but since I had
>problems with it, here's code that should work:
>
>widget.bind(itemName, lambda e, cb=sel.driveEven, itemName=itemName:
>			cb(e,itemName))
>			
>That should do what you want.

It works ! Thanx a lot.

The lambda expression is a bit clearer now !

Ciao
	Matze





More information about the Python-list mailing list