[Python-Dev] Metaclass insanity - another use case (original) (raw)

Aahz aahz@pythoncraft.com
Tue, 5 Nov 2002 18:47:51 -0500


On Wed, Nov 06, 2002, Greg Ewing wrote:

"Phillip J. Eby" <pje@telecommunity.com>:

As for why I had inner classes, the following might be a good example: class ModelElement(Element): class isSpecification(model.Field): isRequired = 1 qualifiedName = 'Foundation.Core.ModelElement.isSpecification' XMINames = ('Foundation.Core.ModelElement.isSpecification',) name = 'isSpecification' referencedType = 'Boolean' I'm not sure if it would be quite what Phillip needs, but I've been wondering recently whether Python could benefit from having an "instance" statement which does for instances what the "class" statement does for classes. The idea is you'd be able to say something like instance isSpecification(model.Field): isRequired = 1 qualifiedName = 'Foundation.Core.ModelElement.isSpecification' and it would be equivalent to isSpecification = model.Field(isRequired = 1, qualifiedName = 'Foundation.Core.ModelElement.isSpecification')

Yeah, but that doesn't gain you all that much over

isSpecification = model.Field(
    isRequired = 1,
    qualifiedName = 'Foundation.Core.ModelElement.isSpecification'
    )

-- Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/

Project Vote Smart: http://www.vote-smart.org/