Hello,

I posted on python-dev a question regarding builtin vars() vs .__dict__
attribute dichotomy:
https://mail.python.org/archives/list/python-...@python.org/thread/JAFIBBUU5UE7VMX3SFYXQOHNK6TDZBV3/

It could as well be one among the earliest cases of the violation of
"There should be one-- and preferably only one --obvious way to do
it." Such earlier, that it could as well turn out that this principle
was never thoroughly followed by Python at all.

Anyway, how the question pops up, is that there's very rare when there's
a need to access *writable* object namespace as dictionary. One of such
cases is executing code in a module context, where you need to pass
module's globals to exec(), and so I wonder what's "the most canonical
way" of getting that - var(mod) or mod.__dict__.

But thinking about it, the problem lies on the exec()'s side. If exec
could take a module object directly as its "globals" param, there
wouldn't be a need to expose internal namespace implementation of the
module object.

So, I wonder what old-timers would think of the following signature:

exec(object[, globals_or_module[, locals]])

https://docs.python.org/3/library/functions.html#exec

-- 
Best regards,
 Paul                          mailto:pmis...@gmail.com
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/TXKQ2G3KFNWXQD6SKM27FCFTENXGEFHJ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to