[Types-sig] Example param/rc declarations

Paul Prescod paulp@ActiveState.com
Thu, 15 Mar 2001 22:19:11 -0800


For those that don't have time to look at os.py, here are some example
declarations:

        class _Environ(UserDict.UserDict):
            def __init__(self, environ):
                __types__= {"environ: Environment": IMapping }
                __paramcheck__()

                UserDict.UserDict.__init__(self)
                data = self.data
                for k, v in environ.items():
                    data[k.upper()] = v
            def __setitem__(self, key, item):
                __types__= {"self: Key to set": IString,
                    "item: Value to insert": IString }
                __paramcheck__()

                putenv(key, item)
                self.data[key.upper()] = item
            def __getitem__(self, key):
                __types__= {"key: Key to get": IString,
                    "_RETURNS: Value": IString }
                __paramcheck__()
                return __rccheck__(self.data[key.upper()])
            def __delitem__(self, key):
                __types__= {"key: Key to delete": IString}
                __paramcheck__()
                del self.data[key.upper()]
            def has_key(self, key):
                __types__= {"self: Key": IString,
                   "_RETURNS: key in dictionary": IStrictBoolean }
                __paramcheck__()
                return __rccheck__(self.data.has_key(key.upper()))

Of course the syntax will be better when we can change Python...

-- 
Take a recipe. Leave a recipe.  
Python Cookbook!  http://www.activestate.com/pythoncookbook