Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.04; 'sys': 0.05; 'builtins': 0.07; 'something,': 0.07; 'subject:when': 0.07; 'python': 0.08; 'ah,': 0.09; 'ambiguity': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'received:gator410.hostgator.com': 0.09; '~ethan~': 0.09; 'ability,': 0.16; 'confusion,': 0.16; 'hmm.': 0.16; 'okay,': 0.16; 'received:72.11': 0.16; 'received:72.11.125': 0.16; 'received:72.11.125.166': 0.16; 'runtime.': 0.16; 'subject:builtin': 0.16; 'wrote:': 0.16; 'wed,': 0.17; '>>>': 0.18; 'figure': 0.21; 'so.': 0.22; 'header:In-Reply-To:1': 0.22; 'aug': 0.24; 'expect': 0.25; 'code.': 0.26; 'function': 0.27; 'language.': 0.28; 'modify': 0.28; 'import': 0.28; 'environment': 0.29; 'lines': 0.30; 'get.': 0.30; 'subject:?': 0.31; 'developers': 0.32; "isn't": 0.33; 'actually': 0.33; 'too': 0.33; 'to:addr:python-list': 0.33; 'that,': 0.33; "i've": 0.34; 'header :User-Agent:1': 0.34; 'creates': 0.34; "we're": 0.34; 'do?': 0.34; 'see,': 0.34; 'stands': 0.34; 'rather': 0.35; 'speaking': 0.35; 'something': 0.37; 'especially': 0.37; 'steven': 0.38; 'subject:: ': 0.39; "there's": 0.39; 'why': 0.39; 'to:addr:python.org': 0.39; "it's": 0.40; 'your': 0.61; 'reached': 0.61; 'received:websitewelcome.com': 0.64; 'mortal': 0.67; 'received:184': 0.67; 'proud': 0.70; 'soon': 0.72; 'certainty.': 0.84; 'heh.': 0.84; 'received:gateway14.websitewelcome.com': 0.84; 'sin.': 0.84; 'tomorrow.': 0.84; 'whatever,': 0.84; 'fish': 0.91 Date: Wed, 17 Aug 2011 10:36:12 -0700 From: Ethan Furman User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: python-list@python.org Subject: Re: Why no warnings when re-assigning builtin names? References: <4e49c89a$0$30001$c3e8da3$5496439d@news.astraweb.com> <4e49fcd7$0$29974$c3e8da3$5496439d@news.astraweb.com> <4e4b1242$0$29966$c3e8da3$5496439d@news.astraweb.com> <4e4b7898$0$29974$c3e8da3$5496439d@news.astraweb.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator410.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-BWhitelist: no X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: mail.admailinc.com ([192.168.10.136]) [72.11.125.166]:3992 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 1 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ== X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1313601591 news.xs4all.nl 23887 [2001:888:2000:d::a6]:43041 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:11700 Seebs wrote: > On 2011-08-17, Steven D'Aprano wrote: >> On Wed, 17 Aug 2011 01:17 pm Seebs wrote: >>> Hmm. See, I've never reached that, in Python or any other language. I >>> figure it creates a new potential for confusion, and that I would rather >>> avoid any ambiguity. I don't *like* ambiguity in code. > >> Ah, well you see the thing is, this is Python. As soon as you call any >> function you don't control, you no longer know what your environment is >> with any certainty. For all you know, the harmless-looking function is >> monkey-patching builtins like there's no tomorrow. Speaking broadly, >> perhaps too broadly, we're incredibly proud of the ability to modify nearly >> everything at runtime. > > Heh. > >> Fortunately, while we are proud of having that ability, actually *using* it >> is considered a mortal sin. We're not Ruby developers -- if you actually >> monkey-patch something, especially built-ins, you can expect to be taken >> outside and slapped around with a fish if you get caught. > > Okay, so. > > Here's what I don't get. > > If it's such a bad thing, *why is it allowed*? Why are you proud of the > ability to do something that you are never socially-allowed to do? Monkey-patching built-ins would be something along the lines of import sys sys.modules['__builtin__'].str = my_super_string and is what stands you in jeopardy of being fish-slapped. ;) Merely shadowing a built-in, or stdlib, or whatever, isn't monkey-patching. ~Ethan~