Georg Schubert Georg Schubert - 2 months ago 7x
Python Question

Can the repetition in this line be avoided?

'=' not in access and name + '.' not in access

I hope to avoid the multiplicity of
not in access
s in a line of Python code. I've used expression evaluation loops for cases of higher numbers of repetitions for convenience but it just seems odd at two.


Here's another option:

all(s not in access for s in ('=', name + '.'))

It's up to you to decide if this is simpler than your code - but at least it avoids having to write not in access twice.