1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

def hoge(self): ←これどうすればいいん?

Last updated at Posted at 2020-12-13

#1.事の起こり

python3
class Hoge:
    def p_hoge(self):
        print("hoge")

このクラス使ってhogeしたいのにselfとか言うやつが邪魔してhoge出来ない!

python3
#こんなエラーが出てる
missing 1 required positional argument: 'self'

#2.解決
クラスをインスタンス化し忘れてるね?

python3
class Hoge:
    def p_hoge(self):
        print("hoge")

x = Hoge()  #ここ!
x.p_hoge()

#hoge

hoge出来たね?

1
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?