[New-bugs-announce] [issue22123] Make object() behave exactly like types.SimpleNamespace() if given kwargs

Mark Summerfield report at bugs.python.org
Sat Aug 2 10:02:28 CEST 2014


New submission from Mark Summerfield:

Right now object() does not accept any args and returns the lightest possible featureless object (i.e., without even a __dict__).

This is great.

However, it is really useful sometimes to be able to create an object to hold some editable state (so not a namedtuple). Right now this can be done with types.SimpleNamespace().

I think it would be a useful enhancement to have object() work as it does now, but to allow it to accept kwargs in which case it would provide identical functionality to types.SimpleNamespace().

This arises from an email I wrote to the python mailinglist:
https://groups.google.com/d/msg/comp.lang.python/9pY7hLp8lDg/voYF8nMO6x8J

But I also think it would be useful more generally.

----------
components: Interpreter Core
messages: 224539
nosy: mark
priority: normal
severity: normal
status: open
title: Make object() behave exactly like types.SimpleNamespace() if given kwargs
type: enhancement
versions: Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22123>
_______________________________________


More information about the New-bugs-announce mailing list