[issue17546] Document the circumstances where the locals() dict gets updated

2013-03-30 Thread Terry J. Reedy
Terry J. Reedy added the comment: /non-local/Non-local/ If we add the hyphen, perhaps we should add 'non-global' also. Thanks for the concrete draft. It is definitely an improvement. The last sentence is somewhat redundant with the second. The problem with the last sentence is that it only sa

[issue17546] Document the circumstances where the locals() dict gets updated

2013-03-30 Thread R. David Murray
R. David Murray added the comment: The problem with using 'nonlocal' is that it would naturally be read as 'those names referenced in a nonlocal statement', which I don't think is the case. Maybe 'non-local', to differentiate it from the keyword? I'm attaching a patch incorporating my underst

[issue17546] Document the circumstances where the locals() dict gets updated

2013-03-30 Thread Éric Araujo
Éric Araujo added the comment: Terry: agreed. -- nosy: +eric.araujo ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscri

[issue17546] Document the circumstances where the locals() dict gets updated

2013-03-30 Thread Terry J. Reedy
Terry J. Reedy added the comment: I also think 'free variable' should be replace by 'nonlocal name'. -- ___ Python tracker ___ ___ Pyt

[issue17546] Document the circumstances where the locals() dict gets updated

2013-03-30 Thread Ned Batchelder
Ned Batchelder added the comment: I would say it something like this: "The dictionary returned by locals() is an accurate snapshot of the local namespace at the time it is called. After the call returns, changes to one may or may not be reflected in the other. The dictionary may change unpre

[issue17546] Document the circumstances where the locals() dict gets updated

2013-03-30 Thread anatoly techtonik
anatoly techtonik added the comment: > them as CPython implementation details and not part of the language definition What is the formal language definition of locals() then? What behavior and functionality of locals() should be supported by all Python implementations? For a potential language

[issue17546] Document the circumstances where the locals() dict gets updated

2013-03-29 Thread Terry J. Reedy
Terry J. Reedy added the comment: After the last exchange on #7083, Guido emailed me that I could/should revised the doc a bit, but he said he did *not* want the details explained because he regards them as CPython implementation details and not part of the language definition. I have not done

[issue17546] Document the circumstances where the locals() dict gets updated

2013-03-29 Thread Terry J. Reedy
Changes by Terry J. Reedy : -- nosy: +terry.reedy ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.p

[issue17546] Document the circumstances where the locals() dict gets updated

2013-03-28 Thread anatoly techtonik
anatoly techtonik added the comment: Ok. Maybe I proposed the solution too early. I am fine with doc fix, but given the previous experience I have doubts it will happen. Maybe opening a wiki page with a current draft can help: http://wiki.python.org/moin/Locals or better http://pirat

[issue17546] Document the circumstances where the locals() dict gets updated

2013-03-28 Thread Eric Snow
Eric Snow added the comment: > Changing the type of the locals() return isn't the right way to solve > this problem. Better docs is the way to do it. If someone is calling > locals(), they should read the docs. Examining the type of values is > discouraged in Python, we shouldn't expect people

[issue17546] Document the circumstances where the locals() dict gets updated

2013-03-28 Thread Ned Batchelder
Ned Batchelder added the comment: Changing the type of the locals() return isn't the right way to solve this problem. Better docs is the way to do it. If someone is calling locals(), they should read the docs. Examining the type of values is discouraged in Python, we shouldn't expect people

[issue17546] Document the circumstances where the locals() dict gets updated

2013-03-28 Thread Georg Brandl
Georg Brandl added the comment: locals() being useful to the majority of Python software is news to me... -- nosy: +georg.brandl ___ Python tracker ___ __

[issue17546] Document the circumstances where the locals() dict gets updated

2013-03-27 Thread anatoly techtonik
anatoly techtonik added the comment: It could be the implementation detail if locals() calls were not useful to majority of Python software, and if behavior of its returned dict did not affect the execution flow of user programs (was deterministic for users who should not care about the implem

[issue17546] Document the circumstances where the locals() dict gets updated

2013-03-27 Thread Eric Snow
Eric Snow added the comment: I've indicated that this issue supercedes issue #7083. -- stage: -> needs patch ___ Python tracker ___ _

[issue17546] Document the circumstances where the locals() dict gets updated

2013-03-27 Thread Ned Batchelder
Changes by Ned Batchelder : -- nosy: +nedbat ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python

[issue17546] Document the circumstances where the locals() dict gets updated

2013-03-27 Thread Eric Snow
Eric Snow added the comment: I should also point out that the following from that note may actually also be a CPython implementation detail: Each call to locals() will return the same dictionary, updated to the contents of the current local symbol table. We'd want to be sure that such sh

[issue17546] Document the circumstances where the locals() dict gets updated

2013-03-27 Thread Eric Snow
Eric Snow added the comment: Okay, I found it. sys.settrace() ultimately results in the setting of tstate->use_tracing to true and sets tstate->c_tracefunc and tstate_c_traceobj (see sys_settrace() in Python/sysmodule.c and PyEval_SetTrace() in Python/ceval.c). tstate->c_tracefunc() gets set

[issue17546] Document the circumstances where the locals() dict gets updated

2013-03-27 Thread Eric Snow
Eric Snow added the comment: Thanks for the script Anatoly. That's pretty much what I was imagining from your description. This definitely reinforces my belief that profiling. -- versions: +Python 3.3, Python 3.4 ___ Python tracker

[issue17546] Document the circumstances where the locals() dict gets updated

2013-03-27 Thread anatoly techtonik
anatoly techtonik added the comment: > "I as a user" can > see and can inspect for further troubleshooting This doesn't work for this example, which was your question. I still feel like this needs further clarification. For a user this behavior is not expected. User is someone who doesn't know

[issue17546] Document the circumstances where the locals() dict gets updated

2013-03-27 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc added the comment: This is expected: "zc = xxx" updates locals! but not the copy. -- ___ Python tracker ___ ___ P

[issue17546] Document the circumstances where the locals() dict gets updated

2013-03-27 Thread bob gailer
bob gailer added the comment: On 3/27/2013 9:48 AM, anatoly techtonik wrote: > anatoly techtonik added the comment: > > Example: > > l = locals() > z = dict(a=5, b=3) > > lc = dict(l) > zc = dict(z) > > print(lc == l) > print(zc == z) > > Gives: > > False >

[issue17546] Document the circumstances where the locals() dict gets updated

2013-03-27 Thread anatoly techtonik
anatoly techtonik added the comment: Example: l = locals() z = dict(a=5, b=3) lc = dict(l) zc = dict(z) print(lc == l) print(zc == z) Gives: False True -- ___ Python tracker ___

[issue17546] Document the circumstances where the locals() dict gets updated

2013-03-27 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc added the comment: > Normal dict in Python is updated by user code (which "I as a user" can > see and can inspect for further troubleshooting) and for locals's dict > this is not correct. Do you have an example? -- ___ Python tra

[issue17546] Document the circumstances where the locals() dict gets updated

2013-03-27 Thread anatoly techtonik
anatoly techtonik added the comment: Amaury, from user's point of view (I am not a core developer - I just need to troubleshoot complicated Python code) the object (the internal structure) returned by locals() has different behavior than a normal dict. Normal dict in Python is updated by user

[issue17546] Document the circumstances where the locals() dict gets updated

2013-03-27 Thread anatoly techtonik
anatoly techtonik added the comment: Eric, here is the code that confirms changed behavior under trace function for both Python 2 and 3 - http://bugs.python.org/file15081/localstest.py I agree that the documentation fix is necessary, and if you say that it is an easier sell - I tend to believe

[issue17546] Document the circumstances where the locals() dict gets updated

2013-03-27 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc added the comment: The previous title, "rename type returned by locals() to livedict" did not describe the reality, since locals() returns a regular dict. [Would you call x.__dict__ a livedict?] So either this issue should be closed as invalid, because it's based on incorr

[issue17546] Document the circumstances where the locals() dict gets updated

2013-03-27 Thread anatoly techtonik
anatoly techtonik added the comment: Raymond, could you please get the title back? You unintentionally hijacked the issue. The "Document the circumstances where the locals() dict gets updated" is not a describing title for this issue - it is one of the possible action items. I'd prefer to see

[issue17546] Document the circumstances where the locals() dict gets updated

2013-03-27 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- assignee: -> docs@python components: +Documentation -Library (Lib) nosy: +docs@python title: rename type returned by locals() to livedict -> Document the circumstances where the locals() dict gets updated ___ Python