Near Final PEP 247 - API for Cryptographic Hash Functions
Oleg Broytmann
phd at phd.pp.ru
Fri Sep 21 07:38:00 EDT 2001
On Fri, Sep 21, 2001 at 03:34:14PM +0400, Roman Suzi wrote:
> > > http://python.sourceforge.net/peps/pep-0247.html
> >
> > Why not to define __repr__ and __str__?
>
>
> > __repr__ = hexdigest
> >
> > def str(self):
> > return "%s(%s)" % (self.__class__.__name__, self.hexdigest())
>
> And more like that, repr representation should be recreatable
> into digest-object again. So I propose to add new constructor which will
> read hexdigest and make approprate object, that is this must be tru:
>
> eval(repr(digestobj)) == digestobj
That was my intention, but I did a mistake. Correct:
__str__ = hexdigest
def __repr__(self):
return "%s(%s)" % (self.__class__.__name__, self.hexdigest())
Oleg.
----
Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru
Programmers don't die, they just GOSUB without RETURN.
More information about the Python-list
mailing list