Calling a class function inside of __init__

前端 未结 6 1861
夕颜
夕颜 2020-12-02 06:13

I\'m writing some code that takes a filename, opens the file, and parses out some data. I\'d like to do this in a class. The following code works:

class MyCl         


        
6条回答
  •  误落风尘
    2020-12-02 06:48

    I think that your problem is actually with not correctly indenting init function.It should be like this

    class MyClass():
         def __init__(self, filename):
              pass
    
         def parse_file():
              pass
    

提交回复
热议问题