8.0
>>> try:
... s.convert_from_text('invalid')
- ... except ValueError, e:
- ... print 'caught a ValueError'
+ ... except ValueError as e:
+ ... print('caught a ValueError')
caught a ValueError
"""
def __init__(self, default=1.0, **kwargs):
... default=2),
... ]
>>> c = MyConfig()
- >>> print c.dump()
+ >>> print(c.dump())
number: one
odd: yes
guesses: 2
- >>> print c.dump(help=True) # doctest: +NORMALIZE_WHITESPACE
+ >>> print(c.dump(help=True)) # doctest: +NORMALIZE_WHITESPACE
number: one (I have a number behind my back... Default: one.
Choices: one, two)
odd: yes (The number behind my back is odd. Default: yes.
def pprint_HDF5(*args, **kwargs):
- print pformat_HDF5(*args, **kwargs)
+ print(pformat_HDF5(*args, **kwargs))
def pformat_HDF5(filename, group='/'):
try:
with _h5py.File(filename, 'r') as f:
cwg = f[group]
ret = '\n'.join(_pformat_hdf5(cwg))
- except IOError, e:
+ except IOError as e:
if 'unable to open' in e.message:
if _os_path.getsize(filename) == 0:
return 'EMPTY'
else:
try:
v = group[s.name][...]
- except Exception, e:
+ except Exception as e:
_LOG.error('Could not access {}/{}: {}'.format(
group.name, s.name, e))
raise
>>> c['alive'] = True
>>> c.save()
- >>> print open(filename, 'r').read() # doctest: +REPORT_UDIFF
+ >>> print(open(filename, 'r').read()) # doctest: +REPORT_UDIFF
age: 1.3
alive: yes
bids:
If you want more details, you can dump with help strings.
->>> print c.dump(help=True) # doctest: +REPORT_UDIFF, +NORMALIZE_WHITESPACE
+>>> print(c.dump(help=True)) # doctest: +REPORT_UDIFF, +NORMALIZE_WHITESPACE
name: (The parrot's name. Default: .)
species: Norwegian Blue (Type of parrot. Default: Norwegian Blue.
Choices: Norwegian Blue, Macaw)