'Making Dot function python
Is it possible to make a dot function that is var.function() that changes var? I realise that i can do:
class Myclass:
def function(x):
return 2
Myclass.function(1):
But i want to change it like the default python function.
def function(x):
return(3)
x=1
x.function()
print(x)
and it returns
>>> 3
Solution 1:[1]
This is weird usage. I suggest you to create custom class to do that, try using @property inside it if you don't want to call function in code.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
