[Chicago] Question about the with statement in Python 2.5

Feihong Hsu hsu.feihong at yahoo.com
Wed Nov 14 20:59:16 CET 2007


Just checking to make sure there's not something I'm missing here, but Python 2.5's with statement cannot be used to define anonymous callback functions, right? For example, the following could not be made to work:

============================================

btn = Button(label="Click me!")
with btn.click:
    print "You pressed the button!"

============================================

I have tried writing my own context manager, but have not found a way to defer the execution of the code inside the with-block.

Thanks,
Feihong

       
---------------------------------
Never miss a thing.   Make Yahoo your homepage.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/chicago/attachments/20071114/f8180ca8/attachment.htm 


More information about the Chicago mailing list