質問内容
クラスとラムダ式を勉強していた時の素朴な疑問です。
ラムダ式の使い方が間違っていると思うのですが、
class_sample.pyを実行したところ
何も表示されずに正常終了しました。
ご解説をお願いします。
2ファイルは同ディレクトリ上にあります。
Python
1# class_sample_org.py 2 3class Train(): 4 def __init__(self,name='train',color='white'): 5 self.name = name 6 self.color = color 7 8 def Name(self): 9 print("this train called {0}".format(self.name)) 10 11 def Color(self): 12 print("this tarin color is {0}".format(self.color)) 13 14class Yamanote(Train): 15 def __init__(self): 16 self.name = 'yamanote' 17 super().__init__('yamanote','green') 18 19 def Name(self): 20 super().Name() 21 22 def Color(self): 23 super().Color()
Python
1#class_sample.py 2 3import class_sample_org as cso 4 5if __name__ == '__main__': 6 yam = cso.Yamanote() 7 tra = cso.Train() 8 train_list = [yam,tra] 9 train_list = map(lambda x: x.Name(), train_list) 10 train_list = map(lambda y: y.Color(), train_list)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/05/28 23:52
2019/05/29 00:16
2019/05/29 02:43