Changeset 786 for trunk/packages


Ignore:
Timestamp:
Jul 30, 2008, 9:05:33 PM (16 years ago)
Author:
price
Message:

expand with_* docstrings in invirt.common

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  
    2727
    2828def 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    """
    3038    def wrapper(func):
    3139        try: return func(rsrc)
     
    4149        print 'locked'
    4250        return raw_input()
    43     # decorator is executed immediately
    44     print input # prints the input text
     51    # prints 'locked'
     52    print input # prints what raw_input() returned
    4553    """
    4654    def wrapper(func):
Note: See TracChangeset for help on using the changeset viewer.