How this code is not giving any error? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How this code is not giving any error?

class Myclass: pass obj=Myclass() obj.n=1000 print (obj.n) As there is no attribute n how can this work

5th Feb 2020, 4:45 AM
Pranshu Nema
Pranshu Nema - avatar
1 Answer
+ 2
You can do similar thing in JS. It's called monkey patching https://stackoverflow.com/questions/5626193/what-is-monkey-patching.
5th Feb 2020, 6:09 AM
Stephan
Stephan - avatar