Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed4.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.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'sys': 0.07; 'builtin': 0.09; 'overwrite': 0.09; 'cc:addr:python-list': 0.11; 'jan': 0.12; '__builtin__': 0.16; 'builtins': 0.16; 'builtins.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'pylab': 0.16; 'roy': 0.16; 'should.': 0.16; 'appropriate': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'work,': 0.20; 'import': 0.22; 'cc:addr:python.org': 0.22; 'module,': 0.24; '(or': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'probably': 0.32; 'skip:_ 10': 0.34; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'executing': 0.36; 'done': 0.36; 'possible': 0.36; 'subject:?': 0.36; 'should': 0.36; 'easiest': 0.38; 'does': 0.39; "you're": 0.61; 'sum': 0.64; 'talking': 0.65; 'smith': 0.68; 'dict.': 0.84; 'snapshot': 0.84; 'subject:handle': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=gy8afQZ/aYpYj7l0ROwWKtyAPDnzrKrYD1y/+5oZcxk=; b=Mj6QcLBJCzxD0wqruybCyCnwe7/6t07KKwbmXMe7GV2K59O5QnPv4NUkaAWDODkraV 0W+Raj2+qC4pRe3hfArgRx9Fi5ewhVUNveFhqF0cQOi2kXoj9DeJmKhVoBm8/YeiaGPf uLmtAeIgrsROsETHbtz+zwSY80GpozeNtz6jtV8s32eP9YIQLIzt6j4Nax/+9Nmg5nhc 95j0odEpjcEHS3c1yTnUQE0ZAmKxwf7/Z/+VAMpADK/gK2vz2kuW+FtPfVCIhhW+kmYw 2ReWAjoankGKd0IVwRIy4MCL2kpWqLNmpOYnNGQVDsIanN+YBajf3ytq8scFT9CEHqLp 5c5A== MIME-Version: 1.0 X-Received: by 10.68.201.10 with SMTP id jw10mr43540423pbc.25.1389219772740; Wed, 08 Jan 2014 14:22:52 -0800 (PST) In-Reply-To: References: Date: Thu, 9 Jan 2014 09:22:52 +1100 Subject: Re: Recover handle to shadowed builtin? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1389219775 news.xs4all.nl 2920 [2001:888:2000:d::a6]:47767 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:63526 On Thu, Jan 9, 2014 at 7:15 AM, Roy Smith wrote: > BUT, not only does pylab overwrite sum(), it overwrites __builtins__ > as well! Instead of a module, it's now a dict. You can still get at > the builtin sum, but you need to do __builtins__["sum"] That probably means that it _only_ overrides the one from __builtins__, which is the easiest way. You're talking about something that's done at the interactive prompt. It should be possible to play with sitecustomize.py to snapshot your original builtins. Try this (untested): # sitecustomize.py import builtins import sys sys.original_builtins = builtins sys.original_sum = sum (or use __builtins__ or __builtin__ or whatever's appropriate for your version) If snapshotting all of builtins doesn't work, snapshotting just sum should. The key is executing code before pylab does its overwriting. ChrisA