def pkt_line(data):
 if (data is None):
  return '0000'
 return (('%04x' % (len(data) + 4)).encode('ascii') + data)

def pkt_line ( data ) : if ( data is None ) : return '0000' return ( ( '%04x' % ( len ( data ) + 4 ) ) . encode ( 'ascii' ) + data )
wrap data in a pkt-line .