Need better string methods

Christian Tismer tismer at stackless.com
Sat Mar 6 22:35:31 EST 2004


William Park wrote:

> Christian Tismer <tismer at stackless.com> wrote:
> 
>>William Park wrote:
>>
>>>Both Bash shell and Python can split based on regular expression.
>>>However, shell is not a bad alternative here:
>>>    tr -s ' \t' ' ' | sed -e 's/ ?| ?/|/g' -e 's/^ //' -e 's/ $//' |
>>>    while IFS='|' read -a clean; do
>>>      ...
>>>    done
>>
>>But isn't that regex expression much harder to understand
>>for part-time programmers than the few Python methods?
> 
> 
> But, OP's audience is not part-time programmers.  My guess is that they
> immediately abandon shell and jump to proprietary languages.  OP may
> have better luck if they stick with shell a bit longer, and then jump to
> Python as last resort.  

I have no idea what OP is.

> As for regex... it's usually easier to set up the data to be cut,
> instead of cutting first and then patching up the pieces.

Why? One big, undecipherable regex is better than a stepwise
reduction of the problem? Not mentioning that the latter is
probably faster, but...
Can you enlighten me why you think you can claim that,
or is this going to become a thread like "PHP is better
than Python for web/database stuff"?

yes-I-meant-to-be-friendly -- chris

-- 
Christian Tismer             :^)   <mailto:tismer at stackless.com>
Mission Impossible 5oftware  :     Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a     :    *Starship* http://starship.python.net/
14109 Berlin                 :     PGP key -> http://wwwkeys.pgp.net/
work +49 30 89 09 53 34  home +49 30 802 86 56  mobile +49 173 24 18 776
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
      whom do you want to sponsor today?   http://www.stackless.com/





More information about the Python-list mailing list