[Python-ideas] Python Object Notation (PyON)

Arnaud Delobelle arnodel at googlemail.com
Sun Nov 2 14:03:45 CET 2008


On 1 Nov 2008, at 19:49, Mathias Panzenböck wrote:

> Arnaud Delobelle schrieb:
>>
>> E.g. can pyon.dumps dump obj accurately for the following value of  
>> obj?
>>
>> lst = [1, 2]
>> obj = [lst, lst]
>>
>> I would expect pyon.dumps(obj) to give something like:
>> """
>> sym0 = [1, 2]
>> obj = [sym0, sym0]
>> """
>>
>
> I wonder what it would yield in this case:
> lst = ['foo']
> lst.append(lst)
>


I guess it could be:
"""
sym0 = ['foo', sym0]
sym0
"""

I.e, one could allow 'assignments' to be made in any order as long as  
all names are eventually defined. E.g.

== pyon form ==
"""
a = [1, b]
b = [a, 2]
a, b
"""

Which would describe the following two objects:

== python form ==
a = [1, None]
b = [None, 2]
a[1] = b
b[0] = 1

The conversion between the two forms seems doable.  Or maybe the  
'python form' should be the 'pyon form', there would b a need for  
extending the syntax so that foo[bar] and foo.bar can appear on the  
left hand side of an assignment.

In that case your 'lst' above could be:
"""
sym0 = ['foo', None]
sym0[1] = sym0
sym0
"""

-- 
Arnaud




More information about the Python-ideas mailing list