Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python override inherited method

import datetime

class Logger(object):
    def log(self, message):
        print message

class TimestampLogger(Logger):
    def log(self, message):
        message = "{ts} {msg}".format(ts=datetime.datetime.now().isoformat(),
                                      msg=message)
        super(TimestampLogger, self).log(message)
Source by www.thedigitalcatonline.com #
 
PREVIOUS NEXT
Tagged: #python #override #inherited #method
ADD COMMENT
Topic
Name
7+3 =