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

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -