On Sat, 2008-02-16 at 20:40 +0100, Dirk Meyer wrote:
> I don't understand. What is dict? Is it the class? If so, what does
> this change do?

Helps to see the whole function in context.  You're confused because the
commit log didn't show the function declaration:

        def make_exception_class(name, bases, dict):
            """
            Class generator for AsyncException.  Creates AsyncException class
            which derives the class of a particular Exception instance.
            """
            def create(exc, stack, *args):
                from new import classobj
                dict.update({
                    # Necessary for python 2.4
                    '__str__': AsyncExceptionBase.__str__
                })
                e = classobj(name, (exc.__class__,) + bases, dict)(*exc.args)
                e._set_info(exc.__class__.__name__, stack, *args)
                return e
        
            return create

The dict is used for creating the class object.  For some reason, with
Python 2.4, it is necessary to explicitly specify methods that the
subclass (AsyncExceptionBase) overrides.  In this case, __str__.  This
is something that changed in python 2.5, evidently.

Note that kaa.config.VarProxy does roughly the same thing, only it's not
implemented with metaclass.

The metaclass stuff is deep python-fu which I only superficially
understand.



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Freevo-devel mailing list
Freevo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freevo-devel

Reply via email to