Strict Type Checking Objects in Python

Warren Postma embed at geocities.com
Mon Mar 27 11:19:34 EST 2000


Has a well documented method already been made to create a static class
definition? For example, to give the type of each attribute, and an
exhaustive list of the values for each attribute, and perhaps then to
instantiate efficiently any number of these objects, all of which references
a single shared "definition" of the valid attributes for a type.  I am
thinking this would be handy for databases.

Warren

--- code snippet --

type_string = type("a") # what is the official "name" of the string type
anyways!?

                    #type,length,null?, .... ?? whatever else ?? .....
attributes_list = {  "name":    (type_string, 80,  non_null, ..... ),
                     "address": (type_string, 100, non_null, ..... )
                  };

class my_obj(typesafe_obj):
        def __init__(self,dict):
            self.dict = dict  # store a reference to a value attribute list
        ....









More information about the Python-list mailing list