class InfixPrintVisitor(object):

    def __init__(self):
        self.expression_string = ''

def visitOperation(self, operation):
    operation.arg1.accept(self)
self.expression_string += ' ' + operation.op + ' '
operation.arg2.accept(self)

def visitInteger(self, number):
    self.expression_string += number.num

def visitFloat(self, number):
    self.expression_string += number.num
How to write the Visitor Pattern for Abstract Syntax Tree in Python?