[Tutor] reset password program

Emile van Sebille emile at fenx.com
Sat Dec 17 01:01:43 CET 2011


On 12/16/2011 2:49 PM ADRIAN KELLY said...
> thanks dave,
> just tried writing to file for the first time
>
> def main():
> outfile.write('Hello this is a test')
> outfile.close()
> main()
>
> *error, globalname outfile is not defined, do i need to import function
> to get this working?*

No, but you do need to initialize outfile appropriately.  The error 
(next time post the entire traceback please -- it provides the specifics 
you'll need to fix the bug) tells you that 'outfile is not defined'

If you set outfile to a writable file object you'll get it going.  Look 
at the 'open' documentation.

HTH,

Emile




More information about the Tutor mailing list