James Stroud wrote:

> By the way, I already know a million "better" ways to do this, so no
> need for the "why would you want to do that?" responses.

why not?

(if you really want to know how this works, study the source code for
the "getargspec" function in the inspect module.  or easier, you can just
use that function to fetch the default:

    def getdefault(function, name):
        import inspect
        args, varargs, varkw, defaults = inspect.getargspec(bob)
        first = len(args) - len(defaults)
        pos = args.index(name)
        if pos >= first:
            return defaults[pos - first]
        return None # no default

    print getdefault(bob, "wives")

)

</F> 



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to