Numeric Customization : to string « Class « Python Tutorial






class Time60(object):            
    def __init__(self, hr, min): 
        self.hr = hr             
        self.min = min           
    def __str__(self):
        return '%d:%d' % (self.hr, self.min)

mon = Time60(10, 30)
tue = Time60(11, 15)

print mon, tue








11.31.to string
11.31.1.Simple Customization
11.31.2.Basic Customization
11.31.3.Numeric Customization
11.31.4.Representation of phone number in USA format: (xxx) xxx-xxxx.