Change a file type in Python?

Chris Angelico rosuav at
Sun Dec 1 00:52:08 CET 2013

On Sun, Dec 1, 2013 at 9:45 AM, Eamonn Rea <eamonnrea at> wrote:
> Is it possible to do so without opening the file again and using the same file object?

In the general sense, no, but you may be able to abuse things terribly
by calling __init__ on an existing object. The only advantage of that
would be if you have multiple references to the file object, so
normally don't - just close it and reopen. You can't change
access/share mode on the file system without closing and reopening, so
ultimately that's going to have to happen.

As a separate point, can you please use a better client than Google
Groups? It's buggy and your posts come out looking ugly. There are
other news clients, or you can sign up for the email list here:


More information about the Python-list mailing list