Class inside a List : List Element « List « Python






Class inside a List

Class inside a List

class B:
    pass
class C(B):
    pass
class D(C):
    pass

for c in [B, C, D]:
    try:
        raise c()
    except D:
        print "D"
    except C:
        print "C"
    except B:
        print "B"


           
       








Related examples in the same category

1.Int, string, function, and list as list elementInt, string, function, and list as list element
2.List items need not all have the same type.List items need not all have the same type.
3.lambda function as a list numberlambda function as a list number