Вопрос

If I define a function, is it ever possible that an exception would be raised for kwargs.get? For example,

def func(**kwargs):
    try:
        a = kwargs.get("a")
    except Exception as e:
        raise ValueError("Would I ever see this error? \n ERROR: %s" % e )
Это было полезно?

Решение

No, kwargs.get('somestring') will not raise an exception; you are passed a standard Python dict type in that case.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top