June 2017
Intermediate to advanced
446 pages
10h 10m
English
Any Python source file can be used as a module, and any functions and classes you define in that source file can be re-used. To load the code, the file referencing the module needs to use the import keyword. Three things happen when the file is imported:
Remember the subtract() function that you defined using the interactive shell? To reuse the function, we can put it into a file named subtract.py:
def subtract(a, b): c = a - b return c
In a file within ...
Read now
Unlock full access