I’m trying to open a file I created and I don´t get it. I suspect that the open function is not using the proper path… How can I put the path?
>>> filehandler = open(fruits.obj,'w')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'fruits' is not defined
The
openfunction takes a string containing the path to your file as its first argument. In your case, you didn’t use a string, but you told Python to use theobjproperty of thefruitsobject. As there is nofruitsobject, you get aNameErrorexception.You should probably change your program to :