Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Jonathan Walker
4,240 Pointscall a variable from another module with user input?
In mod1 there is class, which includes a number of string variables. The point of this question is to try and figure out how to call one of those variables from another module using user input.
in mod2 I have imported everything from mod1 using
from mod1 import *`
During mod2 there is a segment that basically tries to:
call_var = input("What variable? ")
print(mod1_class_instance.call_var)
I know this isn't valid, because Python thinks I'm trying to call a variable within the mod1 class instance named "call_var", but I want the user input (call_var) to be used to reference the variable pre-defined within the instance that has the same name as the user input.
Thank you!