[Tutor] My last

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Wed, 4 Sep 2002 01:14:16 -0700 (PDT)


On Wed, 4 Sep 2002, Morne wrote:

> Could someone please help me with this?
>
> Im really new to any kind of programming and the people at python.org
> return my messages in some other code :not python(lol)The people there
> are cool I just dont seem to understand there answers.  If posible would
> you be able to answer in detail.

When we learn from each other, things have to go in two directions: you
need to tell us exactly where we start sounding ludicrous.  Many of us
have done programming so long that things are beginning to look "obvious"
to us.  Beware us when that happens.  *grin*

We know that, all too easily, things that seem "obvious" aren't obvious at
all. The thing is that we can't tell when we start sounding crazy, so
you've got to wave your hands a bit wildly to bring us back down to Earth.

When you hear a confusing answer, bring it up; perhaps someone here can
put a light on it to make it less mysterious.



> is it wrong of me to send the ppp.log file to just anyone?

It's not "wrong" at all, and it's often really helpful.  If it is a bit
long, then it might be better to post it somewhere on the web and send us
an url instead, to save bandwidth.

An alternative is to just take a few lines of log that cover all the cases
that are being tested for (connections, layers, errors, etc.)  Maybe
around 12 lines or so is good.  It also helps because a smaller case is
easier to check by hand.


I've taken a look at your program: I don't see anything obviously wrong
yet, but you may find it easier if you try for a slightly simpler program
that works, before going after the whole problem.  How about something
like this?

###
def getStuff(file):
    ppplist = file.readlines()
    for line in ppplist:
        print "I am looking at line", line
        if string.file(line, "connect time") >= 0:
            print "found close"
            connectSecs = secondsMatcher.search(line).group(1)
            print "Connected for", connectSecs

def main():
    f = open("C:/my documents/ppp.log", "r")
    getStuff(f)
###

That is, just pay attention to 'connect time' lines in your program for
now.  I've also added a small "I am looking at blah" print statement, so
you can trace out what's happening in the program.


Does this do anything useful with your log?  Do you get any errors, or
does it skip all your log lines without doing anything?  Let's get
something working first: we can always add more to a working program.
It's much harder to get a whole, fully-working program at first go: we
often need to build toward it.