Calling a class function inside of __init__

前端 未结 6 1862
夕颜
夕颜 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:50

    In parse_file, take the self argument (just like in __init__). If there's any other context you need then just pass it as additional arguments as usual.

提交回复
热议问题