[Tutor] Writing to a file on another server

Andrei Kulakov ak@silmarill.org
Wed, 05 Dec 2001 13:22:06 -0500


On Wed, Dec 05, 2001 at 12:31:39PM -0500, Beaudette, Sheree wrote:
> I'm attempting to write to a file but the following code doesn't seem to
> work.  I'm not sure where the file is going if anywhere.  I'm working from
> my machine and developing on a remote server which is where I'm running the
> application that would create this file (the .py file is also located on
> this remote server).  I'd like the file to write to another server ideally.
> Is this possible?
> 
> The following is my code...  I tried using os.chdir but it didn't seem to
> work.  I can't get it to write anywhere it seems
> 
> By default without specifying a path where should the file go?
> 
> def
> write_data(itot,jtot,banknos,bankcontrol1,officersbank,officersno,officersdi
> v, officersdept):
>     import os
>     #os.chdir('/temp)'
>     i=0
>     j=0
>     while i <= itot:
>         fh=open(bk.txt,"w")

fh = open("bk.txt", "w")    # note quotes surrounding the file name

>         fh.write('1 3         COL 1 = FORM,  COL 3 = SPOOL CODE\n')
>         while j <= jtot:
>             fh.write(officersbank[j] + ' ' + officersno[j] + ' ' +
> officersdiv[j] + ' ' + officersdept[j] + '\n')
>             j=j+1
>         i=i+1
>     fh.close()
>     return 1
> 
> Any help would be much appreciated.  I've been working on it for days and am
> getting frustrated!!
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org