私はPythonが初めてで、次の基本的なPython構文を理解しようとしています。前もって感謝します。
foo = self._setup['bar']
更新: 以前のコード セグメントのタイプミスを修正しました。
私はPythonが初めてで、次の基本的なPython構文を理解しようとしています。前もって感謝します。
foo = self._setup['bar']
更新: 以前のコード セグメントのタイプミスを修正しました。
python
はキーワードではないため、これは有効な Python ではありません。
>>> foo = python self._setup['bar']
File "<stdin>", line 1
foo = python self._setup['bar']
^
SyntaxError: invalid syntax
有効な Python コードは次のようになります
foo = self._setup['bar']
これは次のように構成されます。
self # Get the value of self (typically the current object)
self._setup # Get the attribute "_setup" of that value
self._setup['bar'] # Get the item "bar" of the attribute value
foo = self._setup['bar'] # Assign the result to the variable foo
これらはすべて非常に基本的な構造です。詳細については、Python チュートリアルを参照してください。