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: 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: References: Date: Sun, 1 Dec 2013 10:52:08 +1100 Subject: Re: Change a file type in Python? From: Chris Angelico 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 On Sun, Dec 1, 2013 at 9:45 AM, Eamonn Rea 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