Aug-01-2020, 08:13 AM
Dear python users,
As a python newbie I started two months ago learning a bit of coding. By learning some topics of Python some questions came to my mind and I would like to ask here I someone could help me with this case(s). Now I am kind of assuming what the solution would be but I prefer doing it in the correct way avoiding frustrations in the future .
The query:
Inside class objects, should I use the SELF argument only in the __init__ def?
For example:
Hopefully the query description is understandable, please let me know if additional information is needed.
Like to hear!
As a python newbie I started two months ago learning a bit of coding. By learning some topics of Python some questions came to my mind and I would like to ask here I someone could help me with this case(s). Now I am kind of assuming what the solution would be but I prefer doing it in the correct way avoiding frustrations in the future .
The query:
Inside class objects, should I use the SELF argument only in the __init__ def?
For example:
class CountFromBy: def __init__(self, v: int=0, i: int=1): self.val = v self.incr = i def increase(self): self.val += self.incr def __repr__(self) -> str: return str(self.val)And what is the function of "v" and "i" in the __init__ object? Should it be better to used the same initials as "val" behind the self argument?
Hopefully the query description is understandable, please let me know if additional information is needed.
Like to hear!