I want to overload print
statement for my own class.
For example, I have my class named Character_Dict and defined as below:
class Character_Dict(object):
def __init__(self, key_length):
self.char_dict = {}
self.ASCII_dict = {}
self.key_length = key_length
self.dictionary = self.char_dict
self.current_character = ''
For the need of example we have an object named char_dict_object
, which is an instance of Character_Dict
class.
How can I change print
statement to get my self.current_character
printed by using print char_dict_object
?
Thanks in advance for your responses!