Rewriting to Python 3
Ben Finney
ben+python at benfinney.id.au
Fri May 1 03:56:14 EDT 2015
Cecil Westerhof <Cecil at decebal.nl> writes:
> On my system I have:
> PARSER_RE_STR = '/(%s)=' % '|'.join(DN_LUT.keys() + DN_LUT.values())
> in:
> /usr/lib/python3.4/site-packages/ndg/httpsclient/ssl_peer_verification.py
Are you in contact with the author of that third-party library? Why is
it in your Python 3.4 site-packages?
> In Python 3 that gives:
> TypeError: unsupported operand type(s) for +: 'dict_keys' and 'dict_values'
>
> How should I rewrite this?
My attempt:
PARSER_RE_STR = "/({keys}|{values})=".format(
keys=DN_LUT.keys(), values=DN_LUT.values())
Explicit is better than implicit, especially in mini-languages like
string interpolation.
--
\ “Often, the surest way to convey misinformation is to tell the |
`\ strict truth.” —Mark Twain, _Following the Equator_ |
_o__) |
Ben Finney
More information about the Python-list
mailing list