Naming convention
補充:
How to Write Beautiful Python Code With PEP 8 - Real Python
Class initialize
Working with Attributes : Class Constructions and the __ init __ () function
#initialize attributes
class User:
def __init__(self,user_id, username):
self.id = user_id
self.username = username
self.follower = 0 #default value
user_1 = User("001", "Brad")
print(user_1.username)
class User:
def __init__(self,user_id, username):
self.id = user_id
self.username = username
self.follower = 0 #default value
self.following = 0
def follow(self, user):
user.followers +=1
self.following +=1
user_1 = User("001", "Brad")
user_2 = User("002", "Jack")
user_1.follow(user_2)
print(user_1.followers)
print(user_1.following)
print(user_2.followers)
print(user_2.following)
#result:
0
1
1
0
補充: How to Write Beautiful Python Code With PEP 8
How to Write Beautiful Python Code With PEP 8 - Real Python
補充: