Newbie's unsurmountable pb with IO stream trick
gerhard.haering at opus-gmbh.net
Tue Sep 3 10:45:52 CEST 2002
> Peter Hansen <peter at engcorp.com> wrote in message...
>> 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).
cpt = 0
>> 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:
Probably still easier to do with Python code.
> 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!
The popen functions should be useful to interface SQL Plus. I just tried to
do so, but didn't succeed.
>> 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...
Having to use multithreading in Java to get the desired behaviour doesn't
sound too sexy for me.
More information about the Python-list