I’m sure this is going to turn out to be a stupid question… I am trying to break up a string like s = 'P1=12,P2=34,P3=56,P4=78' into a bunch of individual variables:
P1 = 12
P2 = 34
P3 = 56
P4 = 78
s.split(',') gives me a list ['P1=12','P2=34','P3=56','P4=78'], which is a start, I think. Any ideas?
I’d go with something like this:
This will give you a dictionary mapping the names to the values, which is most probably better than trying to create variable dynamically. I f you really want to do the latter, you could also do
but this would be really REALLY horrible.