Yes, you should make a copy of the param string. For me, I use this line to split DNA into a list of rules to make mutating the DNA easier.
actions = dnaString[:-1].split('_')
Note that [:-1]
makes a copy of the string up to the length - 2
index.
I'm doing this because all state machines have a trailing '_'
and splitting that would result in a trailing empty string in my list.
If you don't want to remove that trailing '_'
, you can do dnaString[:]
to make a copy of the string.