43. Dunder Methods : Python

Dunder Methods

Dunker Methods in Python

Techniques beginning with a twofold highlight ( __ ) and finishing with a twofold highlight ( __ ) address Dunder Methods.


__str__ - Method is composed for the end client.


__repr__ - Method is composed for a creator.


Distinction among __str__ and __repr__ Function -

  • On the off chance that the execution of __str__ is missing, __repr__ work is utilized as a fallback. On the off chance that the execution of __repr__ is missing, there will be no fallback.
  • On the off chance that __repr__ work is returning the article's String portrayal, we can skirt the execution of __str__ work.
  • The need of __str__ is higher than __repr__.

Post a Comment

0 Comments