Near Final PEP 247 - API for Cryptographic Hash Functions
Oleg Broytmann
phd at phd.pp.ru
Fri Sep 21 06:35:06 EDT 2001
More information about the Python-list mailing list
Fri Sep 21 06:35:06 EDT 2001
- Previous message (by thread): Near Final PEP 247 - API for Cryptographic Hash Functions
- Next message (by thread): Near Final PEP 247 - API for Cryptographic Hash Functions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, Sep 20, 2001 at 12:20:41PM -0400, Andrew Kuchling 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()) What about processing files? I think it is very common operation, so why not stuff it here? BUFSIZE = 16*1024 def process_file(self, f): if type(f) == type(''): # If f is string - use it as file's name infile = open(f, 'r') else: infile = f # else assume it is file or file-like object try: while 1: buf = infile.read(BUFSIZE) if not buf: break self.update(buf) finally: if type(f) == type(''): # If f was opened - close it infile.close() Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN.
- Previous message (by thread): Near Final PEP 247 - API for Cryptographic Hash Functions
- Next message (by thread): Near Final PEP 247 - API for Cryptographic Hash Functions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list