[python]string to list conversion

I have a file command.txt. It's content are as follows:-

The content of file is actually a command with script name and respective arguments.
arg1 and arg2 are dummy arguments , format : -arg arg_value
test is a argument specifying run mode , format : -arg

In my python code, i read it and store it in a variable named "data"

fin = open(command.txt, "rb")
data = fin.read()
fin.close()

Now i need your help on how should I process "data" to get the scriptname, arg1, run_mode,arg2.
I was trying to convert the "data" into a list and then read values from it using if-else(case) statements.

However- since i am new in python- i am not able to convert data into list, probably the content are not suitable for such conversion.

Please Help!!!

Try this:

# Did this in Python 2.7 - IDLE - Python GUI
>>> ",".join([ x.replace(" ", ",") for x in data.split(" -") ])
'scriptname,arg1,aa,test,arg2,bb'

I hope it helps!