Write a third script that import both of the other as modules, and make sure each module's functionality is embodied in a function (as is Python's best practice), not just "floating" as module-level code -- a module's top-level statements should usually be limited to import
, from
, def
, class
, and simple assignments of names to constants (possibly initial values for global variables), with all actual logic within functions and classes.
So in your third script, after importing the other two as modules, you have a main
function that calls the operating functions of the others to get location and track info, calls a function from standard module datetime
(e.g. datetime.datetime.now()
) -- or possibly time
-- to get the current time, and finally formats all this information in the way you desire and writes it somewhere (where and how do you want to "publish" this info?).
At the end of the script you do
if __name__ == '__main__':
main()
which is the usual Python idiom to ensure the module's main
function executes when the file's being used as the main script rather than just being imported from elsewhere.