[Tutor] Brain In Vice: Why is this so fun to me?

Liam Clarke ml.cyresse at gmail.com
Thu Apr 20 10:46:34 CEST 2006


Yeah, Alan's tutorial is what I used to learn how to code, it's very good.
Regexes are very powerful; which can be a very good thing and a very
bad thing. ;)

Good luck.

On 4/20/06, doug shawhan <doug.shawhan at gmail.com> wrote:
> Got it! Thanks! Mr. Gald hooked me up with his re tutorial as well. Great!
>
>
> On 4/19/06, Liam Clarke <ml.cyresse at gmail.com > wrote:
> > Here's my copy, it should work if you have Tkinter.
> >
> > Good luck!
> >
> > On 4/20/06, doug shawhan <doug.shawhan at gmail.com> wrote:
> > > Drat, I installed from the OpenBSD ports tree and this is not included.
> I'll
> > > scout around on the net.
> > >
> > >  Thanks again!
> > >
> > >
> > > On 4/19/06, doug shawhan <doug.shawhan at gmail.com> wrote:
> > > >
> > > > Holy moley.
> > > >
> > > > Thanks!
> > > >
> > > >
> > > >
> > > > On 4/19/06, Liam Clarke < ml.cyresse at gmail.com> wrote:
> > > > > Hi Doug,
> > > > >
> > > > > Best tip ever is
> > > your_python_dir\tools\scripts\redemo.py
> > > > >
> > > > > Interactive regexes. :)
> > > > >
> > > > > This is pretty good as well -
> > > http://www.amk.ca/python/howto/regex/
> > > > >
> > > > > Good luck,
> > > > >
> > > > > Liam Clarke
> > > > >
> > > > > On 4/20/06, doug shawhan < doug.shawhan at gmail.com> wrote:
> > > > > > I think I'm going to have to suck it up and learn some regular
> > > expressions.
> > > > > >
> > > > > >  I have finally gotten my script (using the excellent pyserial
> module)
> > > to
> > > > > > behave. Most of my troubles as enumerated here before were utterly
> > > > > > self-induced. Apparently one cannot watch the execution of one's
> > > script
> > > > > > through another program without affecting it's outcome in
> unforseen
> > > ways.
> > > > > > (Sound familiar Herr Schroedinger? :-)
> > > > > >
> > > > > >  Now that I am actually extracting data in a fairly predictable
> way, I
> > > am at
> > > > > > the point where I need to parse it! I have some output here
> (modified
> > > to
> > > > > > show  the ESC and NUL characters.)
> > > > > >
> > > > > >  When I pull data from the port, the remote computer sends it in
> one
> > > long
> > > > > > string per screen: newlines are not painted in by using the
> expected
> > > x\0a
> > > > > > that I had hoped for! No easy readlines() fun for me. Instead I
> get:
> > > > > >
> > > > > >  ESC=(  1. ESC=($4x2, 6-239 (3.9L)
> > > > > >
> ..........................................ESC=(a03252
> > > > > > ESC=(k0
> > > > > >  ESC=)  2. ESC=))8-318 ( 5.2L)
> > > > > >
> ..........................................ESC=)a03242
> > > > > > ESC=)k0
> > > > > >  ESC=*  3. ESC=*)8-360 ( 5.9L)
> > > > > >
> ..........................................ESC=*a03351
> > > > > > ESC=*k    0
> > > > > >  ESC=+  4. ESC=+$4x4, 6-239 ( 3.9L)
> > > > > >
> ..........................................ESC=+a03240
> > > > > > ESC=+k    0
> > > > > >  ESC=,  5. ESC=,)8-318 (5.2L)
> > > > > >
> ..........................................ESC=,a03243
> > > > > > ESC=,k    0
> > > > > >  ESC=-  6. ESC=-)8-360 ( 5.9L)
> > > > > >
> ..........................................ESC=-a03352
> > > > > > ESC=-k    0
> > > > > >  ESC=.  7. ESC=.aCH8299  ESCTNULESC)NULESC=%
> > > LINEESCTNULESC=&      R =
> > > > > > RELIST  <return> = NONE
> > > > > >
> > > > > >  I have broken it up for ease of viewing. I need to split the
> string
> > > where
> > > > > > ESC= , k  and 0 are found, but ESC= ,k and 0 are seperated by
> various
> > > > > > spaces, parentheis and other characters that are apparently used
> to
> > > mark the
> > > > > > end of the line until the next ESC is found, thereby displaying a
> new
> > > line
> > > > > > (note how the character after the first ESC on each line is
> repeated
> > > after
> > > > > > the ESC on the end.
> > > > > >
> > > > > >  I cannot for the life of me figure out a pythonic way (read:
> using
> > > the
> > > > > > split() builtin) to scan for instances of these characters in such
> and
> > > such
> > > > > > order and proximity. I know this is what regex is for, but I have
> no
> > > > > > experience.  I have obtained a copy of "Mastering Regular
> Expressions"
> > > but
> > > > > > thought I would inquire here first for caveats and tips as the
> book is
> > > > > > larger than my brain, and I haven't used the re module, ever.
> > > > > >
> > > > > >  Why in the world does this make me so happy? :-)~
> > > > > >
> > > > > > _______________________________________________
> > > > > > Tutor maillist  -   Tutor at python.org
> > > > > > http://mail.python.org/mailman/listinfo/tutor
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
> >
>
>


More information about the Tutor mailing list