Dynamically choosing class to inherit from
Question: My Python knowledge is limited, I need some help on the following situation.

Assume that I have two classes `A` and `B`, is it possible to do something
like the following (conceptually) in Python:

    
    
    import os
    if os.name == 'nt':
        class newClass(A):
           # class body
    else:
       class newClass(B):
           # class body
    

So the problem is that I would like to create a class `newClass` such that it
will inherit from different base classes based on platform difference, is this
possible to do in Python? Thanks.


Answer: You can use a [conditional
expression](http://docs.python.org/2/reference/expressions.html#conditional-
expressions):

    
    
    class newClass(A if os.name == 'nt' else B):
        ...
    

