NOW v0.35 !!! >Re: Python version of IQ has been updates (IQ v0.34.python)

Timothy Rue threeseas at earthlink.net
Mon Jun 18 21:47:27 EDT 2001


On 18-Jun-01 03:59:32 Alex Martelli <aleaxit at yahoo.com> wrote:
>"Timothy Rue" <threeseas at earthlink.net> wrote in message
>news:2509.568T2823T9766233threeseas at earthlink.net...

>> ......... it'd be nice to incorporate into IQ, the ability to
>> access files thru the internet in a way that is as simple as accessing
>> a file on the system you are using IQ on.

>If you use Python, that's trivial -- just open the URL string with
>urllib.urlopen, exactly like you would open a filepath string with
>the builtin function open, and you'll get a file(-like) object ready
>for reading through all the usual fileobject methods (.read, readline,
>etc etc).  If the URL is actually a filepath, urllib.urlopen just
>delegates the work to the built-in open, so you can also choose to
>ALWAYS use urllib.urlopen (when you're opening for _reading_, of
>course -- if you open for *writing*, it's different:-) and it just
>works.  Not sure what the other scripting languages offer for this.

Cool!

Ok I tried it by changing all "open()" to urllib.urlopen() and of
course adding "urllib" to the import line.

But no go.... Actually this message is greatly edited and I do have it
working and a new version 0.35 posted to:

http://home.mindspring.com/~timrue/python/python-IQ.html

I am just reading files so there is no problem with needing to write.

In the process...I know my script uses the tell and seek methods, but
I am also already keeping track of how many lines have been read (which
can replace tell) and can do a readline loop to replace seek. (EVENTUALLY
I was going to have to do this anyway but was using tell and seek because
it's faster or at least was in the case of Arexx)

For the test I'm using the KNMVIC.iq file because it has tagged in it a
valid url (as a file to look thru):
http://www.mindspring.com/~timrue/IQ-1-9-1999.html

That really was extreamly simple in getting Internet file access going!!!
Of course I had a few other things to clean up or change in the process,
but it's DONE!!!

Thank Alex and those on the python IRC channel.

---
*3 S.E.A.S - Virtual Interaction Configuration (VIC) - VISION OF VISIONS!*
   *~ ~ ~      Advancing How we Perceive and Use the Tool of Computers!*
Timothy Rue      What's *DONE* in all we do?  *AI PK OI IP OP SF IQ ID KE*
Email @ mailto:timrue at mindspring.com      >INPUT->(Processing)->OUTPUT>v
Web @ http://www.mindspring.com/~timrue/  ^<--------<----9----<--------<




More information about the Python-list mailing list