Suppose I have a few functions foo_US, foo_EU, foo_JP that are very similar but have minor differences. In main() or some other function, the program is passed an argument region and one of the foo functions is called. What are some different ways to do this, and how can it be done elegantly/ efficiently.
The only way I can think of right now is to define all of the foo functions separately and use if statements to check the region provided, and then call the respective function.
So something like this.
# region = 'US' # for example
if region == 'US':
foo_US()
elif region == 'EU':
foo_EU()
# and so on ...
However this would require that all of the foo_someRegion be declared individually.
Would it be possible to maybe declare a base class for all foo functions, and so for each specific foo function, I would only need to code the minor differences (The foo functions should have the same functionality). Furthermore, is there a way to have a base class country for example, and then have each region as a derived class so that calling foo would result in the respective foo being called? Kind of similar to having a pet base class with cat and dog sub classes where cat.speak() returns meow and dog.cry() returns woof.
Let me know if anything is unclear and any guidance is appreciated. Thank you!
foofunction. In each process there are multiple functions/steps, some which are similar across regions and some not so much. I'm trying to find a relatively elegant way to run the right process when provided with a region.