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 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 nicer
than the original
On Mar 24, 12:39 pm, Peter Waller 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 wiki:
http://pyp
Heh, thanks :)
Unit tests did cross my mind. I was kicking myself for not starting
out with them, there were several regressions during development, and
there could well still be lurking corner cases ;)
I've since heard that a 'better way' would be to use pyparsing. Also,
I saw that python has dr
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!
Interesting!
Might I suggest some unit tests? You can then test all the corner
cases (unmatched b
Peter Waller 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 pondering?” “I think s
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.
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 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
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
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 brace expansion in Pyt
11 matches
Mail list logo