Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'attributes': 0.07; 'override': 0.07; 'returned.': 0.07; 'subject:file': 0.07; 'open()': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:object': 0.16; '2001': 0.18; 'preferred': 0.20; 'parameter': 0.22; "haven't": 0.24; 'seems': 0.24; 'header:User-Agent:1': 0.26; 'header:X-Complaints- To:1': 0.26; "doesn't": 0.28; 'no,': 0.29; 'there.': 0.30; 'classes': 0.30; 'returned': 0.32; "d'aprano": 0.33; 'steven': 0.33; 'to:addr:python-list': 0.35; 'but': 0.36; 'subject:: ': 0.37; 'received:org': 0.38; 'say': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'subject: (': 0.40; 'your': 0.60; 'god': 0.67; '8bit%:21': 0.70; '_o__)': 0.84; 'received:125': 0.84; 'belief': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ben Finney Subject: Re: Returning a custom file object (Python 3) Date: Thu, 28 May 2015 12:40:53 +1000 References: <55667a6d$0$13002$c3e8da3$5496439d@news.astraweb.com> <85iobdwhti.fsf@benfinney.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: jigong.madmonks.org X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-pubkey.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) Cancel-Lock: sha1:TnpuuC3pZuM/82nMej6S95uPzO8= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1432780860 news.xs4all.nl 2852 [2001:888:2000:d::a6]:33139 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:91343 Ben Finney writes: > Steven D'Aprano writes: > > > but how do I tell open() to use MyFile? > > I haven't used it, but does the ‘opener’ parameter do what you want? No, it doesn't; the ‘opener’ parameter doesn't have any say in the type of object returned from ‘open’. It seems the existing ‘open’ implementation doesn't allow you to override the type of object returned. You may have to resort to monkey-patching the ‘io’ attributes to put your preferred classes there. -- \ “Science shows that belief in God is not only obsolete. It is | `\ also incoherent.” —Victor J. Stenger, 2001 | _o__) | Ben Finney