 <p>you dont need to use a list</p> <p>and also it is considered an antipattern to do something like</p> <pre><code>def check(): if condition: return True else: return False </code></pre> <p>since you can just do</p> <pre><code>def check(): return condition </code></pre> <p>all that said ... I think you might be looking for</p> <pre><code>is_sep = lambda char:char in r"(\){}[]" </code></pre> <p>might be what you are looking for ... I guess</p> <pre><code>def is_sep(char): return char in r"(\){}[]" </code></pre> <p>if your set of characters is large you may be better off using a <code>set</code> ... if you are searching a lot of text you may be better served with something like</p> <pre><code>parts = re.split(r"[(\){}[]]",my_complete_text) </code></pre>