Yes, it is possible to refactor multiple assignments after checking for None type. Here is an example:
if my_variable is not None:
a = my_variable.a
b = my_variable.b
c = my_variable.c
This can be refactored using tuple unpacking like this:
if my_variable is not None:
a, b, c = my_variable.a, my_variable.b, my_variable.c
This way, the code is more concise and readable.
Asked: 2022-08-28 11:00:00 +0000
Seen: 13 times
Last updated: Aug 30 '21