Sep-06-2019, 03:15 AM
this a question about the style choice you use for your coding in any language. when you have a case of setting a variable to the result of an expression when a condition is met, or to a literal value otherwise, do you set it to the literal and maybe change it, or do you use if/else to set it either way?
IOW, do you code it like this:
or maybe like this:
IOW, do you code it like this:
location_name = 'nowhere' if location_code: location_name = lookup_location(location_code)or like this:
if location_code: location_name = lookup_location(location_code) else: location_name = 'nowhere'?
or maybe like this:
location_name = lookup_location(location_code) if location_code else 'nowhere'don't assume that i mean that calling a function is always the expression. maybe this is the case of a big complicated expression. would the level of complication determine your choice?
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.