Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Marko Rauhamaa Newsgroups: comp.lang.python Subject: Re: Returning a custom file object (Python 3) Date: Thu, 28 May 2015 08:29:05 +0300 Organization: A noiseless patient Spider Lines: 18 Message-ID: <87wpztclsu.fsf@elektro.pacujo.net> 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 Injection-Info: mx02.eternal-september.org; posting-host="b7cb1518d23ec19d482dcc9c31d30fdd"; logging-data="17942"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+CzOczsvKZ+2fbR4gqHv+V" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:i3mrhrblf0x7YwMCgYzNgdsAq4g= sha1:3DsBaR6Z+wyJM3V/y3KLCYl4/Gg= Xref: csiph.com comp.lang.python:91350 Ben Finney : > It seems the existing ‘open’ implementation doesn't allow you to > override the type of object returned. The question is, can you assign to the builtin namespace. I'm guessing you can't. Within a module, you can simply do: open = MyFile Also, in other modules, you can: from myfile import open Marko