def jsonify ( symbol ) : try : # all symbols have a toJson method, try it return json . dumps ( symbol . toJson ( ) , indent = '  ' ) except AttributeError : pass return json . dumps ( symbol , indent = '  ' )
how to output symbols in python
returns json format for symbol
def jsonify(symbol):
    """ returns json format for symbol """
    try:
        # all symbols have a toJson method, try it
        return json.dumps(symbol.toJson(), indent='  ')
    except AttributeError:
        pass
    return json.dumps(symbol, indent='  ')