How to avoid excessive parameter passing?

后端 未结 6 852
予麋鹿
予麋鹿 2021-02-11 00:22

I am developing a medium size program in python spread across 5 modules. The program accepts command line arguments using OptionParser in the main module e.g. main.py. These opt

6条回答
  •  再見小時候
    2021-02-11 00:50

    With objects, parameter lists should normally be very small, since most appropriate information is a property of the object itself. The standard way to handle this is to configure the object properties and then call the appropriate methods of that object. In this case set p as an attribute of a. Your meth2 should also complain if p is not set.

提交回复
热议问题