`PyObject.item()` should follow the JS convention on undefined keys
mmomtchev opened this issue · 1 comments
mmomtchev commented
The []
operator in JavaScript returns undefined
if the key is not defined, while the same operator in Python raises an exception.
PyObject.item()
should follow the JS convention.
mmomtchev commented
Currently the recommended method to check if a dictionary contains a key before trying to access it is to use the Python in
operator from the operator
module:
(proxified example)
const op = pymport('operator');
if (op.contains(dict, key).toJS()) dict.item(key);