
2011/8/4 Matej Lieskovský <lieskovsky.matej@googlemail.com>:
Um, I'm kinda new round here but here goes: If I understood the problem, we are looking for a way of creating an object which has no specific class. My proposal: perhaps a "namespace" statement would do, behaving somewhat like this: namespace MyObject: statements is equivalent to: class MyClass(object): statements MyObject = MyClass() MyClass = None I chose "namespace" as that's what I think we are trying to create constructive criticism is welcome
Not useful enough to warrant the introduction of a new keyword, IMO. There's some overlap here with the proposed 'given' keyword, and as you noted yourself it can already be done with the class construct. You could use a metaclass/base class or a class decorator to disable instantiation, if you really feel like it. Also note that you can read attributes directly on a class. Finally, you'll want to use the 'del' keyword on your last line. This: del MyClass removes the reference to the class in the namespace, but doesn't actually delete the class itself (until garbage collection and when there's no remaining references - and MyObject is still "referencing" it here).