It is a bad practice to use names that shadow other names that already exist in the same context. It makes code reading and debugging very confusing. Always try to define original names, even if they are local to the context. If you eventually have to reuse existing names or keywords, use a trailing underscore to avoid name collision, for example:
def xapian_query(terms, or_=True): """if or_ is true, terms are combined with the OR clause""" ...
Note that the class keyword is often replaced by klass or cls:
def factory(klass, *args, **kwargs): return klass(*args, **kwargs)
Let's take a look at some of the best practices to keep in mind while working with arguments.