Python Clean Code提示:不要添加冗余上下文

21-08-18 banq
Python clean Code 提示:不要添加冗余上下文 不要向变量名添加不必要的数据,尤其是在使用类时。

# This is bad
class Person:
__init__(self, person_first_name, person_last_name, person_age):
self.person_first_name = person_first_name
self.person_last_name person_last_name
self.person_age = person_age


# This is good
class Person:
def __init__(self, first_name, last_name, age):
self.first_name first_name
self.last_name last_name
self.age = age

 

猜你喜欢