I have a variable like this: ignore = val1,val2
But it's unclear for me how to use these values as separate ones.
Currently (with my knowledge) i need to hard code them like code below:
if (not Path.find("val1") > -1 ) and (not Path.find("val2") > -1 ):
etc
Now i want test added to it, and again i need to hard code it like this:
if (not Path.find("val1") > -1 ) and (not Path.find("val2") > -1 ) and (not Path.find("test") > -1 ):
Isn't there a better way of doing this?
If ignore is a tuple of value names:
if all(Path.find(v) <= -1 for v in ignore):
This has the advantage to stop as soon as the first condition is false. Just like your hard-coded example.
This is a tuple, one of the basic datatypes in Python.
You can access the different values using indexing notation, like ignore[0], ignore[1], etc.
However, if you're struggling with fundamental language features like this, I'd strongly recommend that you go read a Python tutorial before continuing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With