[Baypiggies] Python course for non-programmer

Isaac hyperneato at gmail.com
Mon Mar 5 09:12:25 CET 2007


hmm. I'm a Mac.

> <code>
> import re
>
> def clean(msg):
>  sentences = re.split(r'((?:\.|\?|!|\n\n)\s*)', msg)
this breaks it up

>  capitalized = [s[0:1].capitalize()+ s[1:] for s in sentences]
this capializes the first letter of each element of the list.

>  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

A quick speed read of this:
http://mail.python.org/pipermail/python-list/2003-June/210101.html

leads me to ask if it works if you replace:
sentences = re.split(r'((?:\.|\?|!|\n\n)\s*)', msg)
with
sentences = re.split('((?:\.|\?|!|\n\n)\s*)', msg)
there might be a buglet in Windows and raw strings


from:
http://www.ferg.org/projects/python_gotchas.html#contents_item_2
"""

But don't give despair! There *is* a way...

In Python, there are a number of functions in the os.path module that change
forward slashes in a string to the appropriate filename separator for the
platform that you are on. One of these function is os.path.normcase(). The
trick is to enter all of your filename strings using forward slashes, and
then let os.path.normcase() change them to backslashes for you, this way.

myDirname = os.path.normcase("c:/aDirname/")

It takes a bit of practice to get into the habit of specifying filenames
this way, but you'll find that you adapt to it surprisingly easily, and
you'll find it a *lot* easier than struggling with The Wolf."""

>is there a way to generalize "i'"?  you'd need to support "i'm",
>"i'd", "i'll", etc.
I thought about a file with a pair of words that we can load into a
dictionary- this way we can add acronyms and names. And, I guess, use a real
dictionary to capitalize all proper nouns.

>finally, is there a way to incorporate all your code into gmail so
>that it does it automagically when i click "send"?  :-)

I think I'll have to learn more about the gmail API if it exists for python.


-isaac


On 3/4/07, Mike Cheponis <mac at wireless.com> wrote:
>
> But I think there is a buglet in this code.
>
> When I tried this on unix and my PC, "this" (the word after "Donna") was
> not capitalized.
>
> Just FYI of course!  ;-)
>
> -Mike
>
>
> On Sun, 4 Mar 2007, Isaac wrote:
>
> > Date: Sun, 4 Mar 2007 22:51:15 -0800
> > From: Isaac <hyperneato at gmail.com>
> > To: Python <baypiggies at python.org>
> > Subject: Re: [Baypiggies] Python course for non-programmer
> >
> > This will capitalize the "I" and "I've" and keep the original capitals
> in
> > the 'msg'.
> > Thanks for the inspiration. I had a great time hacking!
> >
> > -Isaac
> > Python newbie
> >
> > <code>
> > import re
> >
> > def clean(msg):
> >  sentences = re.split(r'((?:\.|\?|!|\n\n)\s*)', msg)
> >  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
> >
> > print
> > clean("""donna,
> >
> >
> > this is a good question.  on the flip side, i've developed what
> > i
> > think is a really good course called "Introduction to
> > Programming".
> > there is a "(using Python)" at the end, but i feel that it is not
> > as
> > much about Python as it is about programming in
> > general.
> >
> >
> > the problem is that i've had no venue in order to deliver the
> > course.
> > it's not something that i can just go and market, you know?  how
> > do
> > you contact or reach non-programmers to tell them about a
> > programming
> > class?  i can't very send anything to the mailing list or CLP, so
> > most
> > technical folks *are* programmers!  so although i am ready to
> > teach
> > such a course, i have yet to find a way to deliver
> > it.
> >
> >
> > just go to the website below, and click "Python Training".  look
> > for
> > the "Intro to Programming using Python" class and click once more
> > to
> > get a course description.  maybe if i can find a place to
> > announce
> > this to, i can actually hold this 2-day course!!""")
> > </code>
> > <output>
> > Donna,
> >
> > This is a good question.  On the flip side, I've developed what I
> > think is a really good course called "Introduction to Programming".
> > There is a "(using Python)" at the end, but I feel that it is not as
> > much about Python as it is about programming in general.
> >
> > The problem is that I've had no venue in order to deliver the course.
> > It's not something that I can just go and market, you know?  How do
> > you contact or reach non-programmers to tell them about a programming
> > class?  I can't very send anything to the mailing list or CLP, so most
> > technical folks *are* programmers!  So although I am ready to teach
> > such a course, I have yet to find a way to deliver it.
> >
> > Just go to the website below, and click "Python Training".  Look for
> > the "Intro to Programming using Python" class and click once more to
> > get a course description.  Maybe if I can find a place to announce
> > this to, I can actually hold this 2-day course!!
> > </output>
> >
> > On 3/3/07, Tung Wai Yip <tungwaiyip at yahoo.com> wrote:
> >>
> >> On Fri, 02 Mar 2007 22:58:50 -0800, wesley chun <wescpy at gmail.com>
> wrote:
> >>   ...
> >>   ...
> >>
> >> >>> import re
> >> >>>
> >> >>> def clean(msg, humor=3):
> >> ...     sentences = re.split(r'((?:\.|\?|!|\n\n)\s*)', msg)
> >> ...     capitalized = [s.capitalize() for s in sentences]
> >> ...     return ''.join(capitalized) + ' :)'*humor
> >> ...
> >> >>> print clean("""donna,
> >> ...
> >> ... this is a good question.  on the flip side, i've developed what i
> >> ... think is a really good course called "Introduction to Programming".
> >> ... there is a "(using Python)" at the end, but i feel that it is not
> as
> >> ... much about Python as it is about programming in general.
> >> ...
> >> ... the problem is that i've had no venue in order to deliver the
> course.
> >> ... it's not something that i can just go and market, you know?  how do
> >> ... you contact or reach non-programmers to tell them about a
> programming
> >> ... class?  i can't very send anything to the mailing list or CLP, so
> most
> >> ... technical folks *are* programmers!  so although i am ready to teach
> >> ... such a course, i have yet to find a way to deliver it.
> >> ...
> >> ... """)
> >> Donna,
> >>
> >> This is a good question.  On the flip side, i've developed what i
> >> think is a really good course called "introduction to programming".
> >> There is a "(using python)" at the end, but i feel that it is not as
> >> much about python as it is about programming in general.
> >>
> >> The problem is that i've had no venue in order to deliver the course.
> >> It's not something that i can just go and market, you know?  How do
> >> you contact or reach non-programmers to tell them about a programming
> >> class?  I can't very send anything to the mailing list or clp, so most
> >> technical folks *are* programmers!  So although i am ready to teach
> >> such a course, i have yet to find a way to deliver it.
> >>
> >>   :) :) :)
> >> _______________________________________________
> >> Baypiggies mailing list
> >> Baypiggies at python.org
> >> To change your subscription options or unsubscribe:
> >> http://mail.python.org/mailman/listinfo/baypiggies
> >>
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/baypiggies/attachments/20070305/d112083e/attachment-0001.htm 


More information about the Baypiggies mailing list