[Tutor] Attribute error?

desiderata at softhome.net desiderata at softhome.net
Tue Dec 2 01:27:10 EST 2003


Hi,

This is my first time using python and I've got a problem appending to a
file... here's my short code:

-----
#!/usr/bin/python

uid = raw_input("Please enter your userID: ")
gid = raw_input("Please enter your gID: ")
f = open("file.txt","a")
f.append("\nYour userID is " + uid + " And your gID is " + gid)
-----

but when I input the values while executing it, it gives me an error:

-----
Traceback (most recent call last):
  File "./test2.py", line 6, in ?
      f.append("\nYour userID is " + uid + " And your gID is " + gid) 
      AttributeError: 'file' object has no attribute 'append'
----- 

but I already used "a" for it to append.. I don't get it =( 


regards, 
Elijah




More information about the Tutor mailing list