Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Stripping whitespace

Reply
Thread Tools

Stripping whitespace

 
 
ryan k
Guest
Posts: n/a
 
      01-24-2008
On Jan 23, 6:30 pm, John Machin <sjmac...@lexicon.net> wrote:
> On Jan 24, 9:50 am, ryan k <r...@ryankaskel.com> wrote:
>
> > Steven D'Aprano, you are a prick.

>
> And your reasons for coming to that stridently expressed conclusion
> after reading a posting that was *not* addressed to you are .....?


Because his tone is extremely condescending and quite frankly
annoying. From this post to others, his terse remarks scar this
community and fade its atmosphere of friendliness.
 
Reply With Quote
 
 
 
 
cokofreedom@gmail.com
Guest
Posts: n/a
 
      01-24-2008
On Jan 24, 8:21 am, ryan k <r...@ryankaskel.com> wrote:
> On Jan 23, 6:30 pm, John Machin <sjmac...@lexicon.net> wrote:
>
> > On Jan 24, 9:50 am, ryan k <r...@ryankaskel.com> wrote:

>
> > > Steven D'Aprano, you are a prick.

>
> > And your reasons for coming to that stridently expressed conclusion
> > after reading a posting that was *not* addressed to you are .....?

>
> Because his tone is extremely condescending and quite frankly
> annoying. From this post to others, his terse remarks scar this
> community and fade its atmosphere of friendliness.


And your response was any better because...?
 
Reply With Quote
 
 
 
 
Reedick, Andrew
Guest
Posts: n/a
 
      01-24-2008
> -----Original Message-----
> From: python-list-bounces+jr9445= [mailtoython-
> list-bounces+jr9445=] On Behalf Of John Machin
> Sent: Wednesday, January 23, 2008 5:48 PM
> To: python-
> Subject: Re: Stripping whitespace
>
> On Jan 24, 7:57 am, "Reedick, Andrew" <jr9...@ATT.COM> wrote:
> >
> > Why is it that so many Python people are regex adverse? Use the

> dashed
> > line as a regex. Convert the dashes to dots. Wrap the dots in
> > parentheses. Convert the whitespace chars to '\s'. Presto!

> Simpler,
> > cleaner code.

>
> > pattern = re.sub(r'-', r'.', line)
> > pattern = re.sub(r'\s', r'\\s', pattern)
> > pattern = re.sub(r'([.]+)', r'(\1)', pattern)

>
> Consider this:
> pattern = ' '.join('(.{%d})' % len(x) for x in line.split())
>


Good. But the main drawback to using split+join is that it works if
there is only one whitespace char acting as a column separator
(split+join will compress multiple whitespace characters down to one
char.) Normally, it's safe to assume a one character separator between
columns, however since the input is supposed to be tab delimited (but
wasn't) and tabs tend to get randomly converted to spaces depending on
which butterfly is flapping its wings at any given instant, keeping the
original whitespace column separators is probably a good idea.



*****

The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA622


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Eclipse: Stripping whitespace at EOL Tim Tyler Java 7 09-15-2011 04:07 PM
Problem with stripping leading whitespace in here documents Douglas Wells Ruby 8 01-27-2007 07:46 AM
Strip is not stripping trailing whitespace Taylor Strait Ruby 13 12-28-2006 05:04 PM
Whitespace where I don't want whitespace! Oli Filth HTML 9 01-17-2005 08:47 PM
Stripping whitespace around certain elements Andy Jefferies XML 1 06-26-2003 11:29 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57