Обсуждение: weird code in Python interface

Поиск
Список
Период
Сортировка

weird code in Python interface

От
James Aspnes
Дата:
Sorry to post this to the list but I'm not sure how to track down the
author.  In pg.py and pgsqldb.py in the Python interface (version
6.5.3 RPMs) the following lines of code appear:
  if not hasattr(self,e) and hasattr(self.db,e):     exec 'self.%s = self.db.%s' % ( e, e )

This would be safer, cleaner, and faster if rewritten as:
  if not hasattr(self,e) and hasattr(self.db,e):     setattr(self, e, getattr(self.db, e))

--Jim Aspnes <aspnes@cs.yale.edu>