Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #63526
| References | <mailman.5194.1389210743.18130.python-list@python.org> <lakbkt$n27$1@panix2.panix.com> |
|---|---|
| Date | 2014-01-09 09:22 +1100 |
| Subject | Re: Recover handle to shadowed builtin? |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5204.1389219775.18130.python-list@python.org> (permalink) |
On Thu, Jan 9, 2014 at 7:15 AM, Roy Smith <roy@panix.com> 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
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Recover handle to shadowed builtin? Roy Smith <roy@panix.com> - 2014-01-08 14:52 -0500
Re: Recover handle to shadowed builtin? roy@panix.com (Roy Smith) - 2014-01-08 15:15 -0500
Re: Recover handle to shadowed builtin? Chris Angelico <rosuav@gmail.com> - 2014-01-09 09:22 +1100
csiph-web