Passing an object of class UserList to writelines()
Emile van Sebille
emile at fenx.com
Fri May 18 11:32:00 EDT 2001
You've probably got a list attribute in your class now that can be passed.
If not, you may want to create one.
As I understand it, this is one of the issues that PEPs 252 and 253 looks
towards solving.
HTH
--
Emile van Sebille
emile at fenx.com
---------
"MikeK" <mkent at atlantic.net> wrote in message
news:efd753ca.0105180714.13aaf240 at posting.google.com...
> I created a class derived from UserList to let me easily read a file into
> a list, and write the list back to the file.
>
> I want one of my 'FileListClass' objects to work just like a list, and be
> treated just like a list. However, when I try to pass one of my
> 'FileListClass' objects to the 'writelines' method of an 'os.popen' class
> object, I get the following error:
>
> TypeError: writelines() requires list of strings
>
> This tells me that when I pass my 'FileListClass' object to 'writelines',
> 'writelines' is seeing the object, not the data part of the object.
>
> I'm doing something wrong, possibly in the definition of my
'FileListClass'.
> Any ideas? I'm fairly new to Python, and readily admit that I don't have
a
> firm grasp on writing a Python class.
More information about the Python-list
mailing list