[Python-ideas] Namespace creation with syntax short form
Steven D'Aprano
steve at pearwood.info
Fri Feb 13 11:42:00 CET 2015
On Fri, Feb 13, 2015 at 11:19:58AM +0100, Morten Z wrote:
> Namespaces are widely used in Python, but it appear that creating a
> namespace
> has no short form, like [] for list or {} for dict, but requires the lengthy
> types.SimpleNamespace, with prior import of types.
from types import SimpleNamespace as NS
ns = NS(answer=42)
Python did without a SimpleNamespace type for 20+ years. I don't think
it is important enough to deserve dedicated syntax, especially yet
another overloading of parentheses. Not everything needs to be syntax.
--
Steve
More information about the Python-ideas
mailing list