[Python-ideas] Jump to function as an an alternative to call function

Chris Barker - NOAA Federal chris.barker at noaa.gov
Fri Aug 17 18:16:39 EDT 2018


By the way— really kludgy, doesn’t exec() do what you want here:

Note


The default *locals* act as described for function locals()
<https://docs.python.org/3/library/functions.html#locals> below:
modifications to the default *locals* dictionary should not be attempted.
Pass an explicit *locals*dictionary if you need to see effects of the code
on *locals* after function exec()
<https://docs.python.org/3/library/functions.html#exec> returns.


Though great still may not effect the current local namespace.


But I’d be really surprised if there were no way to modify the local
namespace — you can mess with pretty much anything else in Python.


-CHB



Sent from my iPhone

On Aug 17, 2018, at 12:46 PM, Chris Barker <chris.barker at noaa.gov> wrote:

On Thu, Aug 16, 2018 at 12:37 PM, Chris Angelico <rosuav at gmail.com> wrote:

>
> I've no idea what interpreter you're using, but it doesn't work for me.
>

That was in iPython, with python3.6.2 -- I wouldn't have expected it to be
different in this case though -- really odd.

OK -- tired again, and it indeed it failed -- so I'm really confused. You
can see my console output -- it did indeed work at least once.



> You've changed a cached dictionary but haven't actually created a local
>

which still makes me wonder WHY locals() returns a writable dict...

-CHB


-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180817/80edf463/attachment.html>


More information about the Python-ideas mailing list