Peter Waller wrote:
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
On Mar 24, 5:39 pm, Peter Waller peter.wal...@gmail.com 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 shorter and
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
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 peter.wal...@gmail.com wrote:
Okay, I got fed up with there not being any (obvious) good examples of
how to do bash-like
Peter Waller:
Is there any better way to attach code?
This is a widely used place (but read the contract/disclaimer
first):
http://code.activestate.com/recipes/langs/python/
Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list
2009/3/24 Tino Wildenhain t...@living-examples.com
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
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/3/24 Peter
Peter Waller wrote:
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
Peter Waller peter.wal...@gmail.com writes:
Okay, yuck. I didn't realise that posting would mangle the code so
badly. Is there any better way to attach code?
Yes: Use a news client other than Google Groups.
I'm using google groups.
Fix that, first.
--
\ “Are you pondering what I'm
Peter Waller peter.wal...@gmail.com wrote:
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!
Interesting!
Might I suggest some unit tests? You can then test all
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!
Interesting!
Might I suggest some unit tests? You can then test all the corner
cases (unmatched brackets, empty brackets, etc
On Mar 24, 12:39 pm, Peter Waller peter.wal...@gmail.com wrote:
Maybe I might re-implement this with pyparsing and some unit tests.
In your pyparsing efforts, you might draw some insights from this
regex inverter (that is, given an re such as [AB]\d, returns A0
through B9) on the pyparsing
12 matches
Mail list logo