Question:
Assuming that we have some email addresses in the “username@companyname.com” format, please write a program to print the user name of a given email address, Both user names and company names are composed of letters only.
Hints:
- Use @staticmethod decorator to define class static method.
Solution:
class American(object): @staticmethod def printNationality(): print "America" anAmerican = American() anAmerican.printNationality() American.printNationality()