Consider the following class:
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
My coworkers tend to define it like this:
class Person:
name = None
age = None
def __init__(self, name, age):
self.name = name
self.age = age
The main reason for this is that their IDE of choice shows the properties for autocompletion.
Personally, I dislike the latter one, because it makes no sense that a class has those properties set to None
.
Which one would be better practice and for what reasons?