Q:

Python - Passing arguments to functions

I am sort of new to Python so I was reading through Pro Python and it had this section about passing variable keyword arguments to function. After reading that section I wrote the following code which doesn't seem to work.
def fun(**a):
    return a['height'] if a is not {} else 0

A:

Empty hash from the argument is not guaranteed to be the same object as a newly created empty hash.
Try to compare using a != {}, or just a['height'] if a else 0.
Or even without the check:
return a.get('height', 0)

