Reading PEP 340, it seems to me that blocks could be used for generating 
nested data structures:

def blist(list):
        def enter(parent=None):
                if parent:
                        parent.append(self)
                yield self

x = blist()
block x.enter() as x:
        x.append(1)
        block blist().enter(x) as x:
                x.append(2)
        x.append(3)

print x

this should print [1, [2], 3]

For this to work, the scope of the block variable has to end with the 
end of the block. Currently the PEP leaves this unspecified.

Bye,
    Walter Dörwald
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to