@@ -1978,6 +1978,15 @@ msgid ""
19781978"\n"
19791979"dispatch[get_input()]() # Note trailing parens to call function"
19801980msgstr ""
1981+ "def a():\n"
1982+ " pass\n"
1983+ "\n"
1984+ "def b():\n"
1985+ " pass\n"
1986+ "\n"
1987+ "dispatch = {'go': a, 'stop': b} # 注意:関数にはカッコなし\n"
1988+ "\n"
1989+ "dispatch[get_input()]() # 注意:関数を呼び出すには末尾カッコ"
19811990
19821991#: ../../faq/programming.rst:957
19831992msgid "Use the built-in function :func:`getattr`::"
@@ -1988,6 +1997,8 @@ msgid ""
19881997"import foo\n"
19891998"getattr(foo, 'bar')()"
19901999msgstr ""
2000+ "import foo\n"
2001+ "getattr(foo, 'bar')()"
19912002
19922003#: ../../faq/programming.rst:962
19932004msgid ""
@@ -2013,6 +2024,15 @@ msgid ""
20132024"f = getattr(foo_instance, 'do_' + opname)\n"
20142025"f()"
20152026msgstr ""
2027+ "class Foo:\n"
2028+ " def do_foo(self):\n"
2029+ " ...\n"
2030+ "\n"
2031+ " def do_bar(self):\n"
2032+ " ...\n"
2033+ "\n"
2034+ "f = getattr(foo_instance, 'do_' + opname)\n"
2035+ "f()"
20162036
20172037#: ../../faq/programming.rst:978
20182038msgid "Use :func:`locals` to resolve the function name::"
@@ -2028,12 +2048,21 @@ msgid ""
20282048"f = locals()[fname]\n"
20292049"f()"
20302050msgstr ""
2051+ "def myFunc():\n"
2052+ " print(\" hello\" )\n"
2053+ "\n"
2054+ "fname = \" myFunc\" \n"
2055+ "\n"
2056+ "f = locals()[fname]\n"
2057+ "f()"
20312058
20322059#: ../../faq/programming.rst:990
20332060msgid ""
20342061"Is there an equivalent to Perl's ``chomp()`` for removing trailing newlines "
20352062"from strings?"
20362063msgstr ""
2064+ "文字列から後端の改行を取り除く Perl の ``chomp()`` に相当するものはあります"
2065+ "か?"
20372066
20382067#: ../../faq/programming.rst:992
20392068msgid ""
@@ -2055,6 +2084,11 @@ msgid ""
20552084">>> lines.rstrip(\"\\ n\\ r\" )\n"
20562085"'line 1 '"
20572086msgstr ""
2087+ ">>> lines = (\" line 1 \\ r\\ n\" \n"
2088+ "... \"\\ r\\ n\" \n"
2089+ "... \"\\ r\\ n\" )\n"
2090+ ">>> lines.rstrip(\"\\ n\\ r\" )\n"
2091+ "'line 1 '"
20582092
20592093#: ../../faq/programming.rst:1004
20602094msgid ""
0 commit comments