Quantcast
Channel: Purpose of __repr__ method? - Stack Overflow
Browsing latest articles
Browse All 7 View Live

Answer by srav for Purpose of __repr__ method?

Implement repr for every class you implement. There should be no excuse.Implement str for classes which you think readability is more important of non-ambiguity.Refer this link:...

View Article



Answer by Anh-Thi DINH for Purpose of __repr__ method?

An example to see the differences between them (I copied from this source),>>> x=4>>> repr(x)'4'>>> str(x)'4'>>> y='stringy'>>>...

View Article

Answer by user6516765 for Purpose of __repr__ method?

__repr__ is used by the standalone Python interpreter to display a class in printable format. Example:~> python3.5Python 3.5.1 (v3.5.1:37a07cee5969, Dec 5 2015, 21:12:44) [GCC 4.2.1 (Apple Inc....

View Article

Answer by Jasper Kinoti for Purpose of __repr__ method?

The __repr__ method simply tells Python how to print objects of a class

View Article

Answer by Miki Tebeka for Purpose of __repr__ method?

__repr__ should return a printable representation of the object, most likely one of the ways possible to create this object. See official documentation here. __repr__ is more for developers while...

View Article


Answer by dmazzoni for Purpose of __repr__ method?

This is explained quite well in the Python documentation:repr(object): Return a string containing a printable representation of an object. This is the same value yielded by conversions (reverse...

View Article

Purpose of __repr__ method?

def __repr__(self): return '<%s %s (%s:%s) %s>' % ( self.__class__.__name__, self.urlconf_name, self.app_name, self.namespace, self.regex.pattern)What is the significance/purpose of this method?

View Article
Browsing latest articles
Browse All 7 View Live




Latest Images