Newbie's unsurmountable pb with IO stream trick

Peter Hansen peter at engcorp.com
Mon Sep 2 12:16:34 EDT 2002


Spendius wrote:
> 
> 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 java.io.InputStream.available() !)
> - 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...

Sounds like you're creating a few problems for yourself all
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?

And what does not declaring variables have to do with
the "global keyword issue" (whatever that is)?

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.

If you're just learning Python, you've taken on a fairly
complicated and large task right at the beginning.  Why not
spend some time learning to use it for simpler tasks before
you jump in head first?

Finally, from the description of what you're trying to do
with InputStream.available(), you might have a few options
including opening the file in non-blocking mode or using 
the select module, or something from the win32all package if 
you're running under Windows (you didn't say).

-Peter



More information about the Python-list mailing list