Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!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.025 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'subject:Python': 0.05; 'builtin': 0.07; 'override': 0.07; 'returned.': 0.07; 'subject:file': 0.07; 'builtins': 0.09; 'subsequent': 0.15; "can't.": 0.16; 'guessing': 0.16; 'modules,': 0.16; 'namespace.': 0.16; 'python3:': 0.16; 'shooting': 0.16; 'subject:object': 0.16; 'wrote:': 0.16; 'module,': 0.18; '>>>': 0.20; 'assign': 0.22; 'import': 0.24; 'seems': 0.24; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'question': 0.26; "doesn't": 0.28; "i'm": 0.29; 'skip:_ 10': 0.32; 'probably': 0.32; 'open': 0.33; 'to:addr:python-list': 0.35; 'subject:: ': 0.37; 'doing': 0.38; 'is,': 0.38; 'pm,': 0.39; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'subject: (': 0.40; 'your': 0.60; 'course': 0.64; 'within': 0.64; 'dr.': 0.69; 'yourself': 0.73; 'received:204': 0.75; 'institute': 0.77; '(425)': 0.84; '895-4418': 0.84; 'can:': 0.84; 'digipen': 0.84; 'herron': 0.84; 'pain': 0.84; 'do:': 0.91 Date: Wed, 27 May 2015 22:56:41 -0700 From: Gary Herron User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Returning a custom file object (Python 3) References: <55667a6d$0$13002$c3e8da3$5496439d@news.astraweb.com> <85iobdwhti.fsf@benfinney.id.au> <87wpztclsu.fsf@elektro.pacujo.net> In-Reply-To: <87wpztclsu.fsf@elektro.pacujo.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable 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: 47 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1432792612 news.xs4all.nl 2861 [2001:888:2000:d::a6]:53477 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:91352 On 05/27/2015 10:29 PM, Marko Rauhamaa wrote: > Ben Finney : > >> It seems the existing =E2=80=98open=E2=80=99 implementation doesn't al= low 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 =3D "whatever" >>> Python3: >>> import builtins >>> builtins.open =3D "whatever" >>> Of course doing so is like shooting yourself in the foot: Any=20 subsequent pain is your own fault and probably well deserved. Gary Herron > > Within a module, you can simply do: > > open =3D MyFile > > Also, in other modules, you can: > > from myfile import open > > > Marko --=20 Dr. Gary Herron Department of Computer Science DigiPen Institute of Technology (425) 895-4418