dhp.VI package

Module contents

collection of routines to support python 2&3 code in this package

dhp.VI.iteritems(dct)

return the appropriate method

dhp.VI.py_ver()

return the Major python version, 2 or 3

dhp.VI.set_output_encoding(encoding=u'utf-8')

If Python has punted on output encoding, give it a nudge. (def utf-8)

Python knows the encoding needed when piping to the terminal and automatically sets it. However, when piping to another program (i.e. | less), it is None. Which means it defaults to ascii.

dhp.VI.to_unicode(obj, encoding=u'utf-8')

Convert to unicode if possible.

Parameters:
  • obj (obj) – object to attempt conversion of
  • encoding (str) – default: utf-8

Returns: (unicode|obj)

Exports

The following are exported by dhp.VI

StringIO

The proper version of StringIO from cStringIO or io package.

from dhp.VI import StringIO

InstanceType

Python3 does not have old-style classes so types.InstanceType is undefined. If python3 then InstanceType is set as a pointer to object – which is probably not what you want.

from dhp.VI import InstanceType