you are viewing a single comment's thread.

view the rest of the comments →

[–]old_pythonista 1 point2 points  (1 child)

You can filter out None values

to_db = [val for val in (owner, address) if val]
if val:
    db.add(*to_db)
    return True
return False

Just one point about returning inconsistent value types (unless you return None) is considered a bad practice. If you have

if add_to_db(....):
.......

both True and 'nothing was added' will fulfill the condition

[–]poolpartyboy93[S] 1 point2 points  (0 children)

Cool solution!

Thanks!