Changeset 786 for trunk/packages/sipb-xen-base/files/usr
- Timestamp:
- Jul 30, 2008, 9:05:33 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/sipb-xen-base/files/usr/share/python-support/sipb-xen-base/invirt/common.py
r781 r786 27 27 28 28 def with_closing(rsrc): 29 "Utility to emulate Python 2.5's `with closing(rsrc)` context manager." 29 """ 30 Utility to emulate Python 2.5's `with closing(rsrc)` context manager. 31 32 E.g., 33 @with_closing(file('/tmp/foo')) 34 def contents(f): 35 return f.read() 36 # now 'contents' is the contents of /tmp/foo 37 """ 30 38 def wrapper(func): 31 39 try: return func(rsrc) … … 41 49 print 'locked' 42 50 return raw_input() 43 # decorator is executed immediately44 print input # prints the input text51 # prints 'locked' 52 print input # prints what raw_input() returned 45 53 """ 46 54 def wrapper(func):
Note: See TracChangeset
for help on using the changeset viewer.