Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #60813

Re: Change a file type in Python?

References <d3c7a900-b44a-45da-bab2-9625c01471a7@googlegroups.com>
Date 2013-12-01 10:52 +1100
Subject Re: Change a file type in Python?
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.3428.1385855538.18130.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Change a file type in Python? Eamonn Rea <eamonnrea@gmail.com> - 2013-11-30 14:45 -0800
  Re: Change a file type in Python? Chris Angelico <rosuav@gmail.com> - 2013-12-01 10:52 +1100
    Re: Change a file type in Python? Eamonn Rea <eamonnrea@gmail.com> - 2013-11-30 16:04 -0800
      Re: Change a file type in Python? rusi <rustompmody@gmail.com> - 2013-11-30 19:02 -0800
        Re: Change a file type in Python? Chris Angelico <rosuav@gmail.com> - 2013-12-01 14:22 +1100
          Re: Change a file type in Python? rusi <rustompmody@gmail.com> - 2013-11-30 20:58 -0800
            Re: Change a file type in Python? Chris Angelico <rosuav@gmail.com> - 2013-12-01 16:03 +1100
              Re: Change a file type in Python? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-01 11:20 +0000
      Re: Change a file type in Python? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-01 11:20 +0000
  Re: Change a file type in Python? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-01 00:51 +0000

csiph-web