More concise way of checking if a character is equal to a set of given characters in Python? -


is there cleaner way can write function? kind of thing in python function in standard library, or fancy syntactical feature?

def is_separator(char):     x = ['(', '\'', ')', '{', '}', '[', ']']     c in x:         if char == c:             return true     return false 

i considered using dictionary, imagine theres better way? tried doing char in "(\){}[]" returns false. far above best attempt.

you can rid of for loop , do:

return char in x 

Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -