Reputation: 6152
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 ??
?
Upvotes: 3
Views: 150
Reputation: 647
print(Number.__name__)
# for object
print(Number().__class__.__name__)
Upvotes: 7