views:

34

answers:

1

I have two separate python scripts. One is for getting user location information (which I get from web based geofeed provider.User Gsm is registerd with that services).Another is for retrieving lastfm user track history.I have already able to get user location data and user music track information.

Goal is to map those two script in such a way that I could be able to make relation from those information" Users in certain location are listening certain music in certain time".

Can anybody have nice idea to get this out?Thanks in advance!

+1  A: 

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.

Alex Martelli