I have 3 different modules:
a.py
test_value = 19
........
.......
......
...... # more functions and I need to call every each of it or maybe inherit it
b.py
test_value = 20
....
...
.... #same many functions and each function will need to declare in c.py
My current implementation.
c.py
Here I will call it
import a
import b
String = "I check A"
if "A" in String:
first = a.test_value
second = a.xxxxx
third = a.yyyyy
More continue
else:
first = b.test_value
second = b.xxxxx
third = b.yyyyy
More continue
My expectation.
import a
import b
String = "I check A"
if "A" in String:
first = {}.test_value # the "a" could be replace with depending on the rules.
......more continue
else:
first = {}.test_value # the same here.
more......
My way might be replacing it example:
if "A" in String:
replacement_value = a
else:
replacement_value = b
first = "{}".format(replacement_value).test_value # the "a" could be replace with depending on the rules.
......more continue
this way then I can reuse the code and lessen the number of similar codes but I received erorr : "str' object has no attribute"
Does anyone has any better approach so that I can learn?