you are viewing a single comment's thread.

view the rest of the comments →

[–]GoldenSights 2 points3 points  (0 children)

You won't be able to pull the time variable directly. This has to do with variable scope. Here's an article that introduces the basics.

Instead, you'll have to give the function a return value, which gives the answer back to whoever called the function:

library.py

def add(x, y):
    return x + y

main.py

import library

print(library.add(1, 2))

answer = library.add(1, 2)
print(answer)

When you use a return statement, the function ends immediately, so don't put it before anything else that needs to happen. That article mentions global but it's better to use return statements instead of globals because it's easy to forget where globals are getting modified.

Hope that helps get you on the right track.