I want to write a script that will execute on Linux and Solaris. Most of the logic will be identical on both OS, therefore I write just one script. But because some deployed structure will differ (file locations, file formats, syntax of commands), a couple of functions will be different on the two platforms.
This could be dealt with like
if 'linux' in sys.platform:
result = do_stuff_linux()
if 'sun' in sys.platform:
result = do_stuff_solaris()
more_stuf(result)
...
However it seems to cumbersome and unelegant to sprinkle these ifs
throughout the code. Also I could register functions in some dict
and then call functions via the dict. Probably a little nicer.
Any better ideas on how this could be done?