Reputation: 7449
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
Upvotes: 0
Views: 459
Reputation: 44553
The open
function 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 the obj
property of the fruits
object. As there is no fruits
object, you get a NameError
exception.
You should probably change your program to :
>>> filehandler = open("fruits.obj", "w")
Upvotes: 3