def badcount_error(numallowed, numreceived, numtotal, argnames=None):
    """ Function required x of arguments y (out of z arguments total) to work, but user
        entered wrong amount.  If argnames, error will print the names of attributes required.
        Argnames should be the names of the total number of arguments (eg if numtotal = 4, argnames 
        should be 4 strings)"""
    if argnames:
        return AttributeError(
            'requires %s of %s nonull keywords for %s but received %s.' % (
            numallowed, numtotal, argnames, numreceived))
    else:
        return AttributeError(
            'requires %s of %s nonull keywords but received %s.' % (
            numallowed, numtotal, numreceived))
