is there a whitespace-free python convention?

eichin at metacarta.com eichin at metacarta.com
Mon Feb 10 02:10:32 EST 2003


Hmm, elsewhere in this newsgroup I see spyce (.sf.net) mentioned -- it
does python embedded in html, and uses constructions like:
[[for row in data: {]]    
  <tr>                    
    [[for cell in row: {]]
      <td>[[=cell]]</td>  
    [[}]]                 
  </tr>                   
[[}]]                     

(the [[ ]] mean (mostly) "python statement here"; the { and } are the
invented part that gets translated into "increase indent level" and
"decrease indent level".  

The problem is that I don't see a narrow way to express it - even
saying that ":\s+{$" is the regexp for the leading case could be
confused with nested dictionaries and grouped-multiple lines, ie.

mydict = {"k1": {
  "subk1": 1, "subk2": 2,
  }, "k2": 4}

matches that, but the { can't vanish...

(in spyce, it's sufficient to say "don't do that, then" for the
html-embedded stuff, since you don't transform existing python code
into this, you just reference that directly.  But that doesn't let me
extend it to the cases I care about :)




More information about the Python-list mailing list