printing the short name of a class

Viewed 64

Is there a way to print the short name of a class without the qualifiers? For instance

c = numbers.Number
print(c??)  # should print Number
c = re.Pattern 
print(c??)  # should print Pattern

I know I can use regex to filter out the unwanted text but I am trying to do this for all classes. So what should I put in place of ???

1 Answers
print(Number.__name__)
# for object
print(Number().__class__.__name__)
Related