Python Object Notation (PyON<http://code.google.com/p/pyon/wiki/GettingStarted> ) Python 2.6/3.0 now has a module ast. This opens up new opportunities. One of them is the possibility of introducing human readable/writable literal object notation, based on the syntax of the python language. I would like to know what do you think about this? Best regards, Zaur
Zaur Shibzoukhov wrote:
Python Object Notation (PyON <http://code.google.com/p/pyon/wiki/GettingStarted>)
Python 2.6/3.0 now has a module ast. This opens up new opportunities. One of them is the possibility of introducing human readable/writable literal object notation, based on the syntax of the python language.
Other than syntax details, how is PyON different from json, yaml (3rd party module), and anything else? I see at bottom time comparison with pickle and json, but only that.
I would like to know what do you think about this?
Grammar: <kw> := <name> = <pyon_expr>, ..., <name> = <pyon_expr> There is no rule for pyon_expr. Did you just mean <expr>? ... y=IF( ... flag, ... A1(kind='A1'), ... A2(kind='A2') ... ) Where does IF come from? * extension objects didn't take in mind. needs to be rewritten
On 1 Nov 2008, at 17:09, Terry Reedy wrote:
Zaur Shibzoukhov wrote:
) Python 2.6/3.0 now has a module ast. This opens up new opportunities. One of them is the possibility of introducing human readable/writable literal object notation, based on the syntax of
Python Object Notation (PyON <http://code.google.com/p/pyon/wiki/GettingStarted the python language.
Other than syntax details, how is PyON different from json, yaml (3rd party module), and anything else?
Looking at the page, it seems to me that it aims to: * be able to give a string representation of any(*) object like pickle and unlike json * produce human readable output like json and unlike pickle (*) for a suitable definition of 'any', ideally the same as pickle I guess. That would be good. There are several examples of pyon.loads, but none of pyon.dumps, which would be interesting. 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] """ -- Arnaud
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) -panzi
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
YAML does support type tagging (with ! and !!) so I think a good approach to consider here would be defining a subset of YAML specifically for python compatibility. Furthermore, is there any reason this wouldn't be best integrated with pickle? That is, when I pickle an object, I could specify that it be in "Pyon" format (or maybe "Pyckle") and when I unpickle, it automatically accepts any format? --- Bruce On Sat, Nov 1, 2008 at 12:22 PM, Arnaud Delobelle <arnodel@googlemail.com>wrote:
Zaur Shibzoukhov wrote:
Python Object Notation (PyON < http://code.google.com/p/pyon/wiki/GettingStarted>)
Looking at the page, it seems to me that it aims to:
* be able to give a string representation of any(*) object like pickle and unlike json * produce human readable output like json and unlike pickle
(*) for a suitable definition of 'any', ideally the same as pickle I guess.
participants (5)
-
Arnaud Delobelle -
Bruce Leban -
Mathias Panzenböck -
Terry Reedy -
Zaur Shibzoukhov