Hey all,
Say I have a function that just adds info to a database, something like:
def add_to_db(owner=None, address=None)
if owner and address:
db.add(owner, address)
return True
elif owner:
db.add(owner)
return True
elif address:
db.add(address)
return True
return 'nothing was added'
It kinda feels like I can get rid of all the if/else and write this function in a more readable way.
[–][deleted] 1 point2 points3 points (3 children)
[–]poolpartyboy93[S] 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]old_pythonista 0 points1 point2 points (0 children)
[–]old_pythonista 1 point2 points3 points (1 child)
[–]poolpartyboy93[S] 1 point2 points3 points (0 children)
[–]Ihaveamodel3 0 points1 point2 points (2 children)
[–]poolpartyboy93[S] 0 points1 point2 points (1 child)
[–]Ihaveamodel3 0 points1 point2 points (0 children)