Constructor call in the same class?

Karsten Wutzke kwutzke at web.de
Sun Jul 25 11:41:56 EDT 2010


What's wrong with:

class Enum(RootFragment):
    __jpaTypes = {
        # complete!
        'CascadeType': Enum("javax.persistence.CascadeType"),
        'DiscriminatorType':
Enum("javax.persistence.DiscriminatorType"),
        'EnumType': Enum("javax.persistence.EnumType"),
        'FetchType': Enum("javax.persistence.FetchType"),
        'FlushModeType': Enum("javax.persistence.FlushModeType"),
        'GenerationType': Enum("javax.persistence.GenerationType"),
        'InheritanceType': Enum("javax.persistence.InheritanceType"),
        'LockModeType': Enum("javax.persistence.LockModeType"),
        'PersistenceContextType':
Enum("javax.persistence.PersistenceContextType"),
        'TemporalType': Enum("javax.persistence.TemporalType"),
    }

    # constructor
    def __init__(self, package, modifiers, name, superInterfaces = [],
                 annotations = [], innerClasses = [], properties = [],
methods = []):
        RootFragment.__init__(self, packageName, modifiers, "enum",
name, superInterfaces, annotations, innerClasses, properties, methods)


?

I get

    'CascadeType': Enum("javax.persistence.CascadeType"),

NameError: name 'Enum' is not defined

What's wrong with calling a constructor in a dict initializer? How do
I solve this?

Karsten



More information about the Python-list mailing list