I'm trying to split a string returned from the Python implementation of Interactive Broker's API, but I keep getting a:
AttributeError: 'TickPrice' object has no attribute 'split'
def my_price_handler(msg):
fields=msg.split()
print fields[0]
Checked the API code and (1) msg is a string and (2) 'split' is not redefined elsewhere. Msg string looks like this <Tick Price tickerId=1, field=1, price=74.0, canAutoExecute=1> and can be printed to console directly. Same error message when using syntax:
def my_price_handler(msg):
fields=string.split(msg)
print fields[0]
I have imported string at the top of the program.
Is this a variable scope issue?
isinstance(msg, basestring)ortype(msg) in [str, unicode]? What you have pasted as value ofmsgcould very well be a__str__representation of a class (theTickPricementioned in error message, most likely).