def accept_objects(func):
    """This decorator can be applied to functions whose first argument is a list
    of x, y, z points. It allows the function to also accept a list of objects
    which have x(), y() and z() methods instead."""

    def new_func(objects, *args, **kwargs):
        try:
            points = [(x, y, z) for x, y, z in objects]
        except TypeError:
            points = [(obj.x(), obj.y(), obj.z()) for obj in objects]
        return func(points, *args, **kwargs)
    new_func.__name__ = func.__name__
    new_func.__doc__ = func.__doc__
    return new_func