How do you convert a string obj to a file obj?

Peter Otten __peter__ at web.de
Wed May 4 17:04:37 EDT 2005


Matthew Thorley wrote:

> Ok you're right. tarfile.open expects a string; the path to the file
> open. I thought that I had tried it with open file objects but I guess I
> was mistaken.

tarfile.open()? That would have been important information in your initial
post. 

It would have been even better to just type help(tarfile.open) at the
interactive prompt (remember that next time). Reading the documentation for
you:

"""
open([name[, mode [, fileobj[, bufsize]]]])

...

If fileobj is specified, it is used as an alternative to a file object
opened for name.
"""

So try passing value.file as the third parameter.

Peter



More information about the Python-list mailing list