Re: Bash-like brace expansion

2009-03-26 Thread Peter Waller
On Mar 24, 5:39 pm, Peter Waller wrote: > I've since heard that a 'better way' would be to use pyparsing. Also, > I saw that python has dropped the idea of having recursive regular > expressions at the moment. I've written a pyparsing parser which is very much shorte

Re: Bash-like brace expansion

2009-03-24 Thread Peter Waller
that python has dropped the idea of having recursive regular expressions at the moment. http://bugs.python.org/msg83993 Maybe I might re-implement this with pyparsing and some unit tests. On Mar 24, 2:30 pm, Nick Craig-Wood wrote: > Peter Waller wrote: > >  Okay, I got fed up with ther

Re: Bash-like brace expansion

2009-03-24 Thread Peter Waller
What one really wants is a re option capable of handling recursive structures, something along the lines of what PHP has: http://uk2.php.net/manual/en/regexp.reference.php Under the 'Recursive Patterns' heading. As far as I am aware, no such thing exists for Python (yet?). 2009/

Re: Bash-like brace expansion

2009-03-24 Thread Peter Waller
2009/3/24 Tino Wildenhain > > > The simple {foo} expansion you mention should be quite easily handled > with re.sub and a function as argument. So not much more then a few > lines of code. Could this approach be made to handle recursive expansion? From the example with the script: pprint(BraceE

Re: Bash-like brace expansion

2009-03-24 Thread Peter Waller
Okay, yuck. I didn't realise that posting would mangle the code so badly. Is there any better way to attach code? I'm using google groups. On Mar 24, 12:28 pm, Peter Waller wrote: > Okay, I got fed up with there not being any (obvious) good examples of > how to do bash-like br

Bash-like brace expansion

2009-03-24 Thread Peter Waller
Okay, I got fed up with there not being any (obvious) good examples of how to do bash-like brace expansion in Python, so I wrote it myself. Here it is for all to enjoy! If anyone has any better solutions or any other examples of how to do this, I'd be glad to hear from them. #~ BraceExpand.py - B

Re: Injecting new names into the above frame

2008-09-13 Thread Peter Waller
On Sep 12, 2:30 pm, Carsten Haese <[EMAIL PROTECTED]> wrote: > > The answer to why this doesn't work lies in the disassembly of that > function: This makes me want to ask: is it difficult to modify a function's code? Even if it weren't possible whilst the function was executing (because then I wou

Injecting new names into the above frame

2008-09-12 Thread Peter Waller
Dear Pythoners, I know this will probably be perceived as 'evil voodoo', and fair enough: it probably is. I guess it is unpythonic. .. but I want to know how to do it anyway - mostly for my own interest. Consider the following snippet of code: --- def Get( *names ): if not names: return Non