pythonrepeatnon-repetitive

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 accesss 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.


Solution

  • 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.