exec with partial globals

Chris Angelico rosuav at gmail.com
Tue Oct 30 09:18:57 EDT 2012


On Tue, Oct 30, 2012 at 11:57 PM, Helmut Jarausch
<jarausch at igpm.rwth-aachen.de> wrote:
> Given spreadsheet  S (Source) and D (Destination) as objects (wrapping a
> dictionary) a possible (legal) input would be
>
> D.price= D.price-S.discount
>
> No other fields of 'D' should be modifiable.

That's a bit harder. What you're describing, using exec with specific
globals, would not be able to do this. You'd need to build a proxy
object that decides whether or not to pass on the change.

ChrisA



More information about the Python-list mailing list