Check type existence in Python module
Question: What would be the most Pythonic way of determining if an object's type is
contained in a specific module?

For example, let's say I want to match date, time, and datetime classes from
the datetime module.

    
    
    import datetime
    mylist = [obj1, obj2, obj3, ...]
    for obj in mylist:
        if type(obj) in [datetime.datetime, datetime.time, datetime.date]:
            #Do thing
    

It seems silly creating a matching instance of the three for each loop. Is
there some simpler way of saying "if type(obj) in some-module"?


Answer: [`isinstance()`](https://docs.python.org/3/library/functions.html#isinstance)
can check against multiple types:

> `isinstance(object, classinfo)`
>
> Return true if the object argument is an instance of the `classinfo`
> argument, or of a (direct, indirect or virtual) subclass thereof. If object
> is not an object of the given type, the function always returns false.
> **If`classinfo` is a tuple of type objects (or recursively, other such
> tuples), return true if object is an instance of any of the types**. If
> `classinfo` is not a type or tuple of types and such tuples, a `TypeError`
> exception is raised.
    
    
    if isinstance(obj, (datetime.datetime, datetime.time, datetime.date)):
    

