mirror of
https://bitbucket.org/Mattrixwv/pytutorial.git
synced 2025-12-06 10:13:58 -05:00
Added an example of importing a user created file
This commit is contained in:
11
fileAdd.py
Normal file
11
fileAdd.py
Normal file
@@ -0,0 +1,11 @@
|
||||
#This is a simple test on how to import files and use their functions and classes in python
|
||||
|
||||
#Import the functions from the file
|
||||
#These first two import specific functions from a file
|
||||
#from testImport import testFunction
|
||||
#from testImport import testFunction2
|
||||
#This command imports every function in the file
|
||||
from testImport import *
|
||||
|
||||
print(testFunction())
|
||||
print("The output of the second function is " + str(testFunction2(3, 4)))
|
||||
7
testImport.py
Normal file
7
testImport.py
Normal file
@@ -0,0 +1,7 @@
|
||||
#This is a file with a few functions in it and is used as a test for the fileAdd.py file
|
||||
|
||||
def testFunction():
|
||||
return "This is the test function"
|
||||
|
||||
def testFunction2(num1, num2):
|
||||
return num1 + num2
|
||||
Reference in New Issue
Block a user