Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #91353
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2015-05-28 16:52 +1000 |
| Subject | Re: Returning a custom file object (Python 3) |
| Newsgroups | comp.lang.python |
| References | <55667a6d$0$13002$c3e8da3$5496439d@news.astraweb.com> <85iobdwhti.fsf@benfinney.id.au> <mailman.113.1432780860.5151.python-list@python.org> <87wpztclsu.fsf@elektro.pacujo.net> <mailman.120.1432792612.5151.python-list@python.org> |
| Followup-To | comp.lang.python |
| Message-ID | <5566bb2a$0$11126$c3e8da3@news.astraweb.com> (permalink) |
| Organization | Unlimited download news at news.astraweb.com |
Followups directed to: comp.lang.python
On Thursday 28 May 2015 15:56, Gary Herron wrote: > On 05/27/2015 10:29 PM, Marko Rauhamaa wrote: >> Ben Finney <ben+python@benfinney.id.au>: >> >>> 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. > > Of course you can. > > Python2: > >>> __builtins__.open = "whatever" Don't use __builtins__ with an "s". That's an implementation of CPython and may not exist in the future, and doesn't exist in other implementations. Instead, you should import __builtin__ with no "s". Confusing? It certainly is, which is why Python 3 renamed __builtin__ to builtins. -- Steve
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Returning a custom file object (Python 3) Steven D'Aprano <steve@pearwood.info> - 2015-05-28 12:16 +1000
Re: Returning a custom file object (Python 3) Ben Finney <ben+python@benfinney.id.au> - 2015-05-28 12:40 +1000
Re: Returning a custom file object (Python 3) Marko Rauhamaa <marko@pacujo.net> - 2015-05-28 08:29 +0300
Re: Returning a custom file object (Python 3) Chris Angelico <rosuav@gmail.com> - 2015-05-28 15:49 +1000
Re: Returning a custom file object (Python 3) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-05-28 17:04 +1000
Re: Returning a custom file object (Python 3) Chris Angelico <rosuav@gmail.com> - 2015-05-28 19:06 +1000
Re: Returning a custom file object (Python 3) Gary Herron <gherron@digipen.edu> - 2015-05-27 22:56 -0700
Re: Returning a custom file object (Python 3) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-05-28 16:52 +1000
Re: Returning a custom file object (Python 3) Ben Finney <ben+python@benfinney.id.au> - 2015-05-28 12:34 +1000
Re: Returning a custom file object (Python 3) Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2015-05-28 10:29 +0100
csiph-web