I have some log files that look like many lines of the following:

```
<tickPrice tickerId=0, field=2, price=201.81, canAutoExecute=1>
<tickSize tickerId=0, field=3, size=25>
<tickSize tickerId=0, field=8, size=534349>
<tickPrice tickerId=0, field=2, price=201.82, canAutoExecute=1>

```

I need to define a class of type tickPrice or tickSize. I will need to decide which to use before doing the definition.

What would be the Pythonic way to grab these values? In other words, I need an effective way to reverse str() on a class.

The classes are already defined and just contain the presented variables, e.g., `tickPrice.tickerId`. I'm trying to find a way to extract these values from the text and set the instance attributes to match.

Edit: Answer

This is what I ended up doing-

```
with open(commandLineOptions.simulationFilename, "r") as simulationFileHandle:
    for simulationFileLine in simulationFileHandle:
        (date, time, msgString) = simulationFileLine.split("\t")
        if ("tickPrice" in msgString):
            msgStringCleaned = msgString.translate(None, ''.join("<>,"))
            msgList = msgStringCleaned.split(" ")
            msg = message.tickPrice()
            msg.tickerId = int(msgList[1][9:])
            msg.field = int(msgList[2][6:])
            msg.price = float(msgList[3][6:])
            msg.canAutoExecute = int(msgList[4][15:])
        elif ("tickSize" in msgString):
            msgStringCleaned = msgString.translate(None, ''.join("<>,"))
            msgList = msgStringCleaned.split(" ")
            msg = message.tickSize()
            msg.tickerId = int(msgList[1][9:])
            msg.field = int(msgList[2][6:])
            msg.size = int(msgList[3][5:])
        else:
            print "Unsupported tick message type"

```