<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def matches_extension(path, extension):
 """ Returns True if path has the given extension, or if the last path component matches the extension. Supports Unix glob matching. True False True """

    _, ext = os.path.splitext(path)
    if ext == '':
        # If there is no extension, grab the file name and
        # compare it to the given extension.
        return os.path.basename(path) == extension
    else:
        # If the is an extension, drop the leading period and
        # compare it to the extension.
        return fnmatch.fnmatch(ext[1:], extension)