interface boilerplate

John Hunter jdhunter at ace.bsd.uchicago.edu
Mon Oct 18 10:34:04 EDT 2004


>>>>> "Alex" == Alex Martelli <aleaxit at yahoo.com> writes:

    Alex> Supporting old versions is never going to be easy -- I don't
    Alex> even have a 2.2 installation around to do such tests, any
    Alex> more.  Perhaps for versions < 2.3 you could simply degrade
    Alex> gracefully to perform no renaming (and for versions >= 2.4
    Alex> do the renaming the right way, by assigning to f.func_name
    Alex> and returning f)... those who choose to stick with 2.2 will
    Alex> just have to account that as one of the many limitations and
    Alex> slow-downs their choice buys them...

It is a pain -- for a fair number of linux boxes, though, 2.2 is still
the default.  Perhaps a better alternative for 2.2 is to simply fall back on
exec 

__fmt = """\
def %(name)s(*args, **kwargs):
    try:
        ret =  gca().%(name)s(*args, **kwargs)
    except ValueError, msg:
        msg = raise_msg_to_str(msg)
        error_msg(msg)
    else:
        draw_if_interactive()
        return ret
%(name)s.__doc__ = Axes.%(name)s.__doc__
"""

for name in _methods:
    exec(__fmt%{'name':name})


JDH



More information about the Python-list mailing list