[Tutor] Fw: imported scope

spir denis.spir at free.fr
Wed Apr 29 20:23:51 CEST 2009



Le Wed, 29 Apr 2009 12:32:57 -0400,
Kent Johnson <kent37 at tds.net> s'exprima ainsi:

> On Wed, Apr 29, 2009 at 10:54 AM, spir <denis.spir at free.fr> wrote:
> > Le Wed, 29 Apr 2009 10:05:04 -0400,
> > Kent Johnson <kent37 at tds.net> s'exprima ainsi:
> >> There is some discussion here:
> >> http://mail.python.org/pipermail/python-3000/2007-March/006161.html
> >>
> >> Short answer: __builtins__ is an implementation detail that you should
> >> ignore.
> >>
> >> Kent
> >>
> >
> > Right, thank you, Kent.
> > The issue here is I cannot ignore __buitins__ (or __builtin__). Or maybe
> > I don't understand your answer properly.
> >
> > Yop, sorry, I get it now. It's the same dict in both cases -- except
> > __buitins__ is expanded in the second case... Not obvious! (Is that what
> > you mean?)
> 
> What are you trying to do? Why can't you ignore __builtins__?

Actually, I don't mind of __builtins__, but of vars() or locals(). The issue is that __builtins__ were monstruously ;-) obfuscating a scope dict I needed. In fact, I printed it out to check it contains what I want; when I saw all that stuff there I thought there was something wrong in my method. Actually the dict contains what I need, and only 4 elements. Simply one of them is veeery BIG.

For the sake of information, the reason for this is I need a kind of dynamic scoping, i.e. getting the vars from the caller scope; while python is statically scoped. I cannot find any other way than passing e.g. vars(). Hints welcome.

By the way, I asked previously about the difference between vars() and locals() (couldn't find a situation where they differ). Still have no idea, and there seems to be nothing about that in docs. So why both?

[...] 

> Kent

Denis
------
la vita e estrany


------
la vita e estrany


More information about the Tutor mailing list