Newbie's unsurmountable pb with IO stream trick

Spendius spendius at
Mon Sep 2 10:33:09 EDT 2002

I'm about to give up learning Python because I've met
insurmountable problems. I'm a newbie just having begun
teaching myself this language a few days ago, and I 
already stall against unsolvable (at least to me) issues:
so could you please help me and *show me* I'd be wrong
giving up ?

I tried to rewrite something I wrote in Java, trying to
communicate with an OS process (SQL*Plus in this occurence),
but big time bucked against
- the lack of methods of the so-called 'file objects' (if
  there was an equivalent to !)
- the fact you don't declare variables: you just assign
  values to them => I immediately hit against the 'global'
  keyword issue (rather a global mess) and gave up...

For those who know SQL*Plus y'all know you get a prompt:
"SQL> " 
(remove the "'s to get the string) and then this frontend
Oracle software waits for your input. This is somewhat tricky 
to deal with, but in Java I managed to find a solution [because
your InputStream blocks, which makes your program hang if
you don't address this 'waiting prompt' problem] thanks to
a sub-thread that tries to read the InputStream every time
I detect that the method available() returns 0 (zero): if
the next character in my stream is easily readable -if it
doesn't block- I return it, if it blocks OK I know I've
reached the final 5 characters 'S', 'Q', 'L', '>', ' ' and
that I'll never get the following one, so I return -1 (EOF
in Java).

So I have a challenge for you guys who are enough acquainted
with Python: how could I perform the same with this language ?

Thanks ever so much to y'all...

         (                    )
         (   operating syst.  )
         (    ___________     )
         (   / SQL*Plus  \    )
         (   \__process__/    )
         (    î        |      )
              |        |
              |        |
              |        |
              |       \|/
              |      output str. --->--> sent to a tcl window (for ex.)
            input      ('InputStream' in Java -sic !-)
       (called 'OutputStream'
          in Java !!)
Send "select sysdate from dual;" to the input stream & you'll get
the output stream string (remove the "'s):
"SQL> "

More information about the Python-list mailing list