Newbie's unsurmountable pb with IO stream trick

Spendius spendius at
Tue Sep 3 04:09:33 EDT 2002

Peter Hansen <peter at> wrote in message...

OK I forgot to say I'm trying to develop my stuff under Windoze.

> at once here.  For one thing, why are you trying to use 
> global variables at all when the original code was in
> Java, which doesn't have such things?
Do you mean Java doesn't have global variables or I'm mistaken ?!?
> And what does not declaring variables have to do with
> the "global keyword issue" (whatever that is)?
I kept getting the error message
# UnboundLocalError: local variable 'cpt' referenced before assignment
where I really didn't expect to get such an error, and noticed in this
forum a lot of guys who know Python complain and talk themselves about
a "mess" (my 'cpt' var. is a counter incremented every time a method
gets called and I must sometimes re-initialize it to 0 inside an 'if'
statement: merely IMPOSSIBLE). 
> If you have an SQL database to access, why not use one of the
> standard DBAPI modules to get to it?  You might be doing a lot
> of extra work when you don't have to.
And why not ? Anyway SQL*Plus contains plenty of built-in commands
that allow you to format your output how you like: I'd like to
keep that functionality. And let's say that I want to do that for
the sole purpose of learning the handling of IO streams in Python !
> If you're just learning Python, you've taken on a fairly
> complicated and large task right at the beginning.  Why not
I admit it. But I did *exactly* the same with Java (writing
the app I'm trying to port) but never got stuck into problems
that blocking...

More information about the Python-list mailing list