Numeric Customization : To string : Class PYTHON TUTORIALS


PYTHON TUTORIALS » Class » To string »

 

Numeric Customization


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(1030)
tue = Time60(1115)

print mon, tue



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Class
» To string