On Tue, Mar 29, 2016 at 9:52 AM, Steven D'Aprano <st...@pearwood.info> wrote: > That would be called "type" :-) > > type(name, bases, namespace) returns a new class: > > > py> C = type("MyClass", (object,), {'foo': 1}) > py> C > <class '__main__.MyClass'> > py> C.foo > 1
Yeah, but to do that in a single expression, you need to have all the functions in the dictionary, so it's no improvement over SimpleNamespace. The functions get attached to the class, not the instance, which means they need 'self' - but without assignment, you wouldn't be able to make much use of self anyway. Hence the call for an example. ChrisA -- https://mail.python.org/mailman/listinfo/python-list