Proposal for new operators to python that add syntactic sugar for hierarcical data.

bruno at modulix onurb at xiludom.gro
Thu May 18 20:40:47 CEST 2006


glomde wrote:
>>What you are trying to achieve is to make syntactic sugar for making namespace
>>definitions look nicer. But: the way you are trying to do so isn't pythonic,
>>because there isn't one obvious way how your proposal works; you're not even
>>specifying a proper semantic interpretation of your syntax (and use "magic"
>>markers, which is even more a NoNo).
> 
> I used 'magic' markers, since I am lousy at coming up with new
> keywords....

This is an understatement.

(snip)
> But I'll try to formalize it a little bit more.
> 
> I am proposing two new keywords 'node' and 'attr'. Which have the
> syntax:
> 
> node [callable|name][:]
> 
> This will append itself to the current node if it is a callable. If it
> is a name it
> will become the new current node. The current node has the scope of the
> block
> or until a new node is created.
> 
> attr name = expression
> This will set the attribute name to expression on the current node.

We already have this (quite close to) this syntax:

class <name>(super):
  <name>=<attr_value> *
  [class *]

There's also the Zope3 'implements' trick, that allow to modify the
class namespace without assignement:

class <name>:
   <callable>(*args, **kw)*

So what you want is very certainly doable without any syntax change.


> I dont think it is the same as the  'make' but I wouldnt rule it
> out.....

It has already been ruled out IIRC.


-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list