[Tutor] Proper useage of "open"

Alan Gauld alan.gauld at btinternet.com
Wed Dec 12 22:30:09 CET 2012


On 12/12/12 21:09, frank ernest wrote:
> I want to open a file so I read the library useage because I could not
> recall the propor useage.
> I typed in to my script:
> a = open (dupli, r)
> and got an error stating that "dupli" is not deffined.

It sounds as if dupli is the name of your file however you have passed 
it into open without quotes so Python thinks it is a variable. Except it 
has no variables called dupli....

Similarly the mode (r) should also be passed as a string.

In future please always post the full error text from your session,
its easier than us guessing and the messages often include subtle 
details that you may not have noticed...

HTH
-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list