'Class method isn't changing the value
Consider a class:
class Whatever:
rang = 'itselop'
def __init__ (self, name):
self.name = name
self.suka = name + " " + ' musorskaya'
@classmethod
def func(cls, attr):
cls.rang = attr
No error, if this passed in. I write then Whatever.func = 'patskak', expecting that this value shoud overwrite the class variable. But the class variable remains. I thought, this is because strings are immutable; but same thing repeats, when I make 2 integers as the class variable and the class method agrument. Why? Thank you.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
