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


Groups > comp.lang.python > #60813

Re: Change a file type in Python?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!proxad.net!feeder1-2.proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.013
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'subject:Python': 0.06; 'abuse': 0.07; 'subject:file': 0.07; '__init__': 0.09; 'happen.': 0.09; 'buggy': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'sense,': 0.16; 'subject:Change': 0.16; 'subject:type': 0.16; 'terribly': 0.16; 'wrote:': 0.18; 'normally': 0.19; 'separate': 0.22; 'posts': 0.26; 'references': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'dec': 0.30; 'mode': 0.30; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'object.': 0.31; 'file': 0.32; 'url:python': 0.33; "can't": 0.35; 'no,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'google': 0.35; 'there': 0.35; 'object,': 0.36; 'url:listinfo': 0.36; 'possible': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'list': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'url:mail': 0.40; 'here:': 0.62; 'news': 0.67; 'close': 0.67; '9:45': 0.84; 'clients,': 0.95; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=DbCbuuMkrgmVLjFbndA4Dth1vTViHqHT4SDjehhD4XY=; b=sHTAm/5duwx6X1OB02twMqrZ6BT7sZ/feT9fU0iNOvG+qlPCQF935xlwvkjlG6DIfb nfeZcVAiZpyzW7cjEzpM5JiSSw44S7WjWVgkCMnomhbMf8s7IPbD/RWmwIaorSMIC7hQ +9PRku1nDpgJW0juUOQnjvcNVpVFxqP3sMjSib7yu+SiRUgmPZARhUdCbXOVVi9WqZY8 06kIQxSyYvm5Q78vXf6Hbc+ymDkrF9jpTr0AlvIdGCB8Ao+zzKHwCnxT4L+y5kleMiBD pG8Vs9Wy7mdpVlPvyOWZR7D6oqDk05urJBBLvvbhajW+NpgQwNbcin0+oikGNWRrVLlG w1Kg==
MIME-Version 1.0
X-Received by 10.68.233.135 with SMTP id tw7mr23407210pbc.112.1385855528710; Sat, 30 Nov 2013 15:52:08 -0800 (PST)
In-Reply-To <d3c7a900-b44a-45da-bab2-9625c01471a7@googlegroups.com>
References <d3c7a900-b44a-45da-bab2-9625c01471a7@googlegroups.com>
Date Sun, 1 Dec 2013 10:52:08 +1100
Subject Re: Change a file type in Python?
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3428.1385855538.18130.python-list@python.org> (permalink)
Lines 17
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1385855538 news.xs4all.nl 15906 [2001:888:2000:d::a6]:58404
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:60813

Show key headers only | 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