これは私が何をしたいのストリップダウンバージョンです:文字列にその名前が与えられた変数の値を取得する方法は?簡単にするために
def foo(a):
# I want to print the value of the variable
# the name of which is contained in a
私はPHPでこれを行う方法を知っている:これを行うには
function foo($a) {
echo $$a;
}
global $string = "blah"; // might not need to be global but that's irrelevant
foo("string"); // prints "blah"
任意の方法?
'地元の人々()':別のモジュールの値を取得するには、
getattr
を使用することができます。 –