私はパッケージングスクリプトをテストし、将来の使用のためにそれらをインストールしようとしています。私はスクリプト 'my_script.py'を作成し、 python docs\setup.py develop
でインストールしました。うまくインストールされているので、うまくいきました。このコードは、これを含んでいた:私は '名前は定義されていません' Pythonで私が作成し、 'distribution'でインストールしたパッケージを参照するとき
from my_script import test
tool = (1, 2, 3, 4, 5, 6)
test_print(self, tool)
、それが戻っています:私は間違って
Traceback (most recent call last):
File "bin\test2.py", line 5, in <module>
test_print(self, tool)
NameError: name 'test_print' is not defined
何をやっているの
class test(object):
def test_print(self, tool):
for i in tool:
print i
は、その後、私は言うスクリプトを作成しましたか?
インポートが正常に動作すると仮定すると、それでも 'test()。test_print(tool) 'でなければなりません。 'test_print'は' test'クラスのインスタンスメソッドです。また、 'self'引数を渡さず、クラス内でのみ使用されます。 – orangeInk