In Python, given the string'int', how can I get the type int? Using getattr(current_module, 'int') doesn’t work.
In Python, given the string ‘int’ , how can I get the type int
Share
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.
intisn’t part of the namespace of your current module; it’s part of the__builtins__namespace. So you would rungetattron__builtins__.To verify that it’s a type you can just check whether it’s an instance of
type, since all types are derived from it.