[Baypiggies] Python course for non-programmer

Isaac hyperneato at gmail.com
Tue Mar 6 08:21:17 CET 2007


I can't tell if this will work because I do not have access to Python on
Windows or Gnu-Linux

This is a guess after I searched The Google for hints or suggestions and
found nothing specific. My reasoning is that because Python >2.3 already has
Universal newline support I need to look for 2 consecutive instances of
that, *not* specifically '\n\n'.

<code>
import re

def clean(msg):
    sentences = re.split(r'((?:\.|\?|!|\n{2})\s*)', msg) #this is the only
line I changed.

    capitalized = [s[0:1].capitalize() + s[1:] for s in sentences]

    capitalized_2 = ''.join(capitalized)

    break_msg = re.split('(\s)', capitalized_2)
    i_noun = [re.sub('^i$', 'I', i) for i in break_msg]

    i_ve_noun = [re.sub('i\'ve', 'I\'ve',i) for i in i_noun]

    I = ''.join(i_ve_noun)
    return I
</code>

Cheers

-Isaac

On 3/5/07, Stephen McInerney < spmcinerney at hotmail.com > wrote:
>
> Can you rewrite it with  Universal Newline Support ?
>
> It is ugly to have hard \n\n or \n\r
>
> Thanks,
> Stephen
>
>
> >From: "wesley chun" <wescpy at gmail.com>
> >To: Isaac < hyperneato at gmail.com>
> >CC: Python <baypiggies at python.org>
> >Subject: Re: [Baypiggies] Python course for non-programmer
> >Date: Mon, 5 Mar 2007 11:49:53 -0800
> >
> > > is not splitting msg correctly because windows and unix have different
>
> > > newline characters.(?)
> >
> >hence Universal Newline Support back in 2.3:
> >
> > http://www.python.org/dev/peps/pep-0278/
> >
> >-wesley
> >_______________________________________________
> >Baypiggies mailing list
> >Baypiggies at python.org
> >To change your subscription options or unsubscribe:
> >http://mail.python.org/mailman/listinfo/baypiggies
>
> _________________________________________________________________
> Play Flexicon: the crossword game that feeds your brain. PLAY now for
> FREE.
>   http://zone.msn.com/en/flexicon/default.htm?icid=flexicon_hmtagline
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/baypiggies/attachments/20070305/d100539b/attachment.html 


More information about the Baypiggies mailing list