def _prtfmt ( self , item_id , dashes ) : ntprt = self . id2nt [ item_id ] dct = ntprt . _asdict ( ) self . prt . write ( '{DASHES:{N}}' . format ( DASHES = self . fmt_dashes . format ( DASHES = dashes , ID = self . nm2prtfmt [ 'ID' ] . format ( * * dct ) ) , N = self . dash_len ) ) self . prt . write ( "{INFO}\n" . format ( INFO = self . nm2prtfmt [ 'ITEM' ] . format ( * * dct ) ) )
python print namedtuple string formatting
Print object information using a namedtuple and a format pattern .
def _prtfmt(self, item_id, dashes):
        """Print object information using a namedtuple and a format pattern."""
        ntprt = self.id2nt[item_id]
        dct = ntprt._asdict()
        self.prt.write('{DASHES:{N}}'.format(
            DASHES=self.fmt_dashes.format(DASHES=dashes, ID=self.nm2prtfmt['ID'].format(**dct)),
            N=self.dash_len))
        self.prt.write("{INFO}\n".format(INFO=self.nm2prtfmt['ITEM'].format(**dct)))