Skip to content

Instantly share code, notes, and snippets.

@knotech
Created February 10, 2015 22:11
Show Gist options
  • Save knotech/acea08600e34ba365e05 to your computer and use it in GitHub Desktop.
Save knotech/acea08600e34ba365e05 to your computer and use it in GitHub Desktop.
## This file will be printit.py
#!/usr/bin/env/python3
def printit(string):
print(string)
## This file will be in the same directory and called import_printit.py .
#!/usr/bin/env python3
from printit import printit
if __name__ == '__main__':
string = input("String to print.")
printit(string)
## running the second file will import the function printit from the file printit.py
## the printit function will be available in the global name space of the program
## import_printit.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment