Is there a way to have a default value if the number of values to unpack is too little compared to the variable list?
For example:
a, b, c = read_json(request)
This works if read_json
returns an array of three or more variable. If it only returns two, I get an exception while assigning c
. So, is there a way to set c
to a default value if it can't be unpacked properly? Something like:
a, b, (c=2) = read_json(request)
Which is similar to what you do when defining a function with default arguments.
Thank you!