Is there a Python equivalent to Ruby symbols?
-
If so then what is it?
-
If not then are we stuck with using strings as our keys in dictionaries only?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, python doesn’t have a symbol type.
However string literals are interned by default and other strings can be interned using the
internfunction. So using string literals as keys in dictionaries is not less performant than using symbols in ruby.