What’s the difference between a instance variable and a field? /u/ItsBlueSkyz Python Education

Is there a difference between the following and if there is when should i use one over the other? Thanks.

1.

class person: name: str = 'alice' 

2.

class person: def __init__(self, name): self.name = 'alice' 

submitted by /u/ItsBlueSkyz
[link] [comments]

​r/learnpython Is there a difference between the following and if there is when should i use one over the other? Thanks. 1. class person: name: str = ‘alice’ 2. class person: def __init__(self, name): self.name = ‘alice’ submitted by /u/ItsBlueSkyz [link] [comments] 

Is there a difference between the following and if there is when should i use one over the other? Thanks.

1.

class person: name: str = 'alice' 

2.

class person: def __init__(self, name): self.name = 'alice' 

submitted by /u/ItsBlueSkyz
[link] [comments] 

Leave a Reply

Your email address will not be published. Required fields are marked *