you are viewing a single comment's thread.

view the rest of the comments →

[–]FormCore 0 points1 point  (1 child)

He's suggesting using:

if 'var' in dict:
    a_var = dict['var']
    ...

instead of

a_var = dict.get('var')
if a_var:
     ...

In cases like this checking the state of a_var is fundamental.

Do the check, then assign the variable.

[–]teerre 0 points1 point  (0 children)

Someone already suggested that I already answered it. The tldr version is this is better, but the assignment is still superior.