Dynamically choosing class to inherit from

后端 未结 5 1613
离开以前
离开以前 2021-02-02 07:30

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 somet

5条回答
  •  迷失自我
    2021-02-02 08:09

    You can use a conditional expression:

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

提交回复
热议问题