On Thursday 15 April 2004 18:36, Angus Leeming wrote: > > Yes, but it would be more elegant still if I could save the stream > rather than convert it to a list. Is that possible?
Notice that you can get information easily from inside a python interpreter: * import sys * we know that sys.stdout is a file, ask which methods are available for it, >>>dir(sys.stdout) ['__class__', '__delattr__', '__doc__', '__getattribute__', '__hash__', '__init__', '__iter__', '__new__', '__reduce__', '__repr__', '__setattr__', '__str__', 'close', 'closed', 'fileno', 'flush', 'isatty', 'mode', 'name', 'read', 'readinto', 'readline', 'readlines', 'seek', 'softspace', 'tell', 'truncate', 'write', 'writelines', 'xreadlines'] * So the likely candidate will be in the read family, to have the basic information for each >>> help(sys.stdout.read) This is quite handy. As another example to know which methods a list has it is simple: >>> dir([]) The same for a string: >>> dir("") You get the feeling. :-) -- José Abílio LyX and docbook, a perfect match. :-)