Re: [Pyparsing] pyparsing svg - noob
Brought to you by:
ptmcg
From: Donn I. <don...@gm...> - 2007-11-08 15:18:37
|
> float = ... whatever ... AAARRRGGGHHH! :) A Homer moment. > phrase = OneOrMore(Group(command)) # what I would recommend instead > My recommended version of phrase makes each command its own nested list, > like: > [['M', [float,float]], > ['C',[float,float,float,float,float,float]], > ['L',[float,float]], > ['Z']] > Your recc. phrase is producing this: M [['269.78326', '381.27104']] This is ok. C [['368.52151', '424.27023'], ['90.593578', '-18.581883'], ['90.027729', '129.28708']] This is 3 lists of 2 coords. Not a train smash, but not a single list of 6 coords. It's to do with the nature of a 'couple' I think. > for command,couples in tokens[:-1]: Now that is cool, but strange. I printed tokens[:-1] out and, oh boy, there's tupels in lists and dics too! Heck, as long as it works. \d |