# DRY version of this one line if/else for property's existence [closed]

I have an object for which I wish to modify a property if a condition is met, else leave it virginal.

I find my current code to be very repetitive and would instead like to use a more succinct form, but am unsure of how to lambda-fy it or at least tell it to pass if condition not met:

my_object.unique_id = 'TBC' if not my_object.unique_id else my_object.unique_id


I guess this is nicer, but still repetitive:

if not my_object.unique_id: my_object.unique_id = 'TBC'


I would like something more like

my_object.unique_id = 'TBC' if None


Is there a way to only reference the property once?

my_object.unique_id = my_object.unique_id or 'TBC'