I have imported a file using the below command
code='IN'
exec "import %s_tmp_file" % code
Now i want to use this same imported file for other operations. How to give the file name in that case?
str = code_tmp_file.dict # this does not work.
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.
Use the
__import__builtin instead ofexec:See this page or
help(__import__)for more information.