Proposal for new operators to python that add syntactic sugar for hierarcical data.
Bruno Desthuilliers
bdesth.quelquechose at free.quelquepart.fr
Thu May 18 21:09:14 EDT 2006
Heiko Wundram a écrit :
> Am Freitag 19 Mai 2006 02:08 schrieb Bruno Desthuilliers:
>
>>We'd need the make: statement, but the BDFL has pronounced against.
>>
>>I'm still -2 against your proposition, but it could make a good use case
>>for the make statement. I gave an eye at the new 'with' statement, but
>>I'm not sure it could be used to solve this.
>
>
> Couldn't. "with" is a blatant misnomer for that it's functionality is
> (basically a "protected" generator), at least if you know what with does in
> VB (god, am I really comparing VB with Python?
Lol !-)
> And I've never even programmed
> in the former...)
I did in a previous life. And believe me, this is kind of a WTF
language... To quote the poet : "Dumb all over, a little ugly on the side".
But I was not thinking about anything related to VB's 'with' !-)
Just about what other (than class) statements defines a block that then
becomes a namespace you can manipulate.
Something like:
with Node('root') as root:
with Node('head') as head:
with Node('title') as title:
title.content = "Page Title"
for s in section:
with Node('section %s' % s['title']) as section:
section.content = s['content']
Now the question is : how to we get the Node objects back ? If possible
without adding them explicitely to the parent object ? (which would not
solve the problem of the root Node anyway).
More information about the Python-list
mailing list