human
Complete this python program:
def clear_memoized_methods(obj, *method_names):
assistant
#Here is the Python code you requested.

    """Clear the memoized method or @memoizeproperty results for the given
    method names from the given object.
    >>> v = [0]
    >>> def inc():
    ...     v[0] += 1
    ...     return v[0]
    >>> class Foo(object):
    ...    @memoizemethod
    ...    def foo(self):
    ...        return inc()
    ...    @memoizeproperty
    ...    def g(self):
    ...       return inc()
    >>> f = Foo()
    >>> f.foo(), f.foo()
    (1, 1)
    >>> clear_memoized_methods(f, \foo\)
    >>> (f.foo(), f.foo(), f.g, f.g)
    (2, 2, 3, 3)
    >>> (f.foo(), f.foo(), f.g, f.g)
    (2, 2, 3, 3)
    >>> clear_memoized_methods(f, \g\, \no_problem_if_undefined\)
    >>> f.g, f.foo(), f.g
    (4, 2, 4)
    >>> f.foo()
    2
    """
    for key in list(getattr(obj, '_memoized_results', {}).keys()):
        if (key[0] in method_names):
            del obj._memoized_results[key]
    property_dict = obj._cache_
    for prop in method_names:
        inner_attname = ('__%s' % prop)
        if (inner_attname in property_dict):
            del property_dict[inner_attname]