thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phillip B Oldham <phillip.old...@gmail.com>
Subject [Python] enabling the `with` statement?
Date Thu, 03 Sep 2009 10:53:35 GMT
Are there plans to enable use of the python `with` statement?

For example, it would be useful to be able to do something like the
following (server implementation):

with MyThriftObject.containedObject as obj:
    myvariable = obj.foo
    # do something here

or:

obj = MyThriftObject()
obj.containedObjects = []
for my_dict in my_list_of_dicts:
    with ContainedObject() as c:
        # map my_dict to c here
        obj.containedObjects.append(c)

Currently python throws errors such as:
  AttributeError: 'MyThriftObject' object has no attribute '__exit__'

-- 
Phillip B Oldham
phillip.oldham@gmail.com
+44 (0) 7525 01 09 01

Mime
View raw message