In Javascript it would be:
var newObject = { \'propertyName\' : \'propertyValue\' };
newObject.propertyName; // retur
Python 3.3 added the SimpleNamespace class for that exact purpose:
>>> from types import SimpleNamespace
>>> obj = SimpleNamespace(propertyName='propertyValue')
>>> obj
namespace(propertyName='propertyValue')
>>> obj.propertyName
'propertyValue'
In addition to the appropriate constructor to build the object, SimpleNamespace
defines __repr__
and __eq__
(documented in 3.4) to behave as expected.