を持って、私はこの問題に遭遇したとき、私はpygameのプロジェクトに取り組んでいた:は、Python
# Note: pos is the tuple that stores mouse position
self.start_on = lambda: True if pos[1] >= 100 and pos[1] <= 200 else False
print(self.start_on)
戻り
<function Menu.mouseLogic.<locals>.<lambda> at 0x10346d1e0>
の代わりに、TrueまたはFalse。
私も試してみました:
self.start_on = (lambda: True if pos[1] >= 100 and pos[1] <= 200 else False)
print(self.start_on)
が、それは同じことを返します。
どのようにしてTrueまたはFalseを返すのですか?
(注:これはのpython 3.5である)
名前にラムダ(無名関数)を割り当てたい場合は、代わりに通常の 'def'を使用してください。 – skrx