• Kursy
  • Kompilator kodu
  • Dyskusja
  • Cennik
  • Zespoły
Menu
+ 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

pythonclassesattributespython3oop
5th Feb 2020, 4:45 AM
Pranshu Nema
Pranshu Nema - avatar
1 Odpowiedź
+ 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

Często masz takie pytania?

Ucz się bardziej efektywnie, za darmo:

  • Wprowadzenie do Pythona

    7.1M uczących się

  • Wprowadzenie do Java

    4.7M uczących się

  • Wprowadzenie do C

    1.5M uczących się

  • Wprowadzenie do HTML

    7.5M uczących się

Zobacz wszystkie kursy
Popularne dzisiaj
Which is easier to learn first between python and JS?
0 Votes
Does sololearn teaches on how to create games
0 Votes
Excuse me, why do they always ask us to input without telling us what it is for in python.
2 Votes
Sockets, etc
0 Votes
Quiz
0 Votes
I HAVE A PROBLEM I CANNOT ABLE TO SEND MESSAGE ANYONE AND ALSO MY MESSAGE SECTION NOT AVAILABLE "PLEASE ACTIVATE YOUR ACCOUNT
0 Votes
Necesitó ayuda
1 Votes
Any Sololearn Chat Groups that I could Join?
0 Votes
Controls issue
0 Votes
can't understand an error
0 Votes