Change a file type in Python?

Chris Angelico rosuav at gmail.com
Sat Nov 30 18:52:08 EST 2013


On Sun, Dec 1, 2013 at 9:45 AM, Eamonn Rea <eamonnrea at gmail.com> 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:

https://mail.python.org/mailman/listinfo/python-list

ChrisA



More information about the Python-list mailing list