[pypy-dev] [mdione at grulic.org.ar: modifying locals]
Marcos Dione
mdione at grulic.org.ar
Thu Oct 15 16:47:57 CEST 2015
On Thu, Oct 15, 2015 at 04:14:02PM +0200, Armin Rigo wrote:
> Hi Marcos,
>
> On Wed, Oct 14, 2015 at 12:58 PM, Marcos Dione <mdione at grulic.org.ar> wrote:
> > inception_locals= sys._getframe().f_back.f_locals
> > inception_locals.update (locals)
>
> I think this works if you *assign* to f_locals. When you only *read*
> f_locals, you get a copy of the dict. The assignment is needed to
> write the new values back into the frame's real ("optimized") locals:
>
> inception_locals= sys._getframe().f_back.f_locals
> inception_locals.update (locals)
> sys._getframe().f_back.f_locals = inception_locals
AttributeError: attribute 'f_locals' of 'frame' objects is not writable
so no cigar here. on the other hand, this works:
http://mike.verdone.ca/media/Dangerously%20Advanced%20Python.pdf [p21]
so I'll keep investigating :-]
> A bientôt,
À+ :)
--
(Not so) Random fortune:
Army General: [shouting] You told us that windows 98 would be faster,
and more efficient with better access to the internet!
Bill Gates: It IS faster! Over five million...
[General shoots Bill Gates in the face and everyone cheers]
-- South Park
More information about the pypy-dev
mailing list