From 1cef96ff5f6f7840128d7c01f57163cd004cb745 Mon Sep 17 00:00:00 2001 From: Jose Windows Date: Sat, 24 Feb 2018 12:28:40 -0800 Subject: [PATCH 1/2] updating on modules --- ...xpressions-Map-and-Filter-checkpoint.ipynb | 2 +- ...05-Lambda-Expressions-Map-and-Filter.ipynb | 2 +- ...ct 1 - Complete Walkthrough Solution.ipynb | 34 +++----- .../01-Modules and Packages-checkpoint.ipynb | 0 .../00-Modules_and_Packages/mymodule.py | 5 ++ .../00-Modules_and_Packages/myprogram.py | 34 ++++++++ .../01-Name_and_Main/Explanation.txt | 76 ++++++++++++++++++ .../01-Name_and_Main/one.py | 9 +++ .../01-Name_and_Main/two.py | 10 +++ .../Useful_Info_Notebook.ipynb | 0 ...s and Exceptions Handling-checkpoint.ipynb | 0 ...s and Exceptions Homework-checkpoint.ipynb | 0 ...tions Homework - Solution-checkpoint.ipynb | 0 .../04-Unit Testing-checkpoint.ipynb | 0 .../01-Errors and Exceptions Handling.ipynb | 0 .../02-Errors and Exceptions Homework.ipynb | 0 ...s and Exceptions Homework - Solution.ipynb | 0 .../04-Unit Testing.ipynb | 0 .../__pycache__/cap.cpython-36.pyc | Bin .../cap.py | 0 .../simple1.py | 0 .../simple2.py | 0 .../test_cap.py | 0 .../testfile | 0 ...ne Project 2 - Assignment-checkpoint.ipynb | 0 ...alkthrough Steps Workbook-checkpoint.ipynb | 0 ...lete Walkthrough Solution-checkpoint.ipynb | 0 ...Project 2 - Solution Code-checkpoint.ipynb | 0 .../01-Milestone Project 2 - Assignment.ipynb | 0 ...oject 2 - Walkthrough Steps Workbook.ipynb | 0 ...ct 2 - Complete Walkthrough Solution.ipynb | 0 ...-Milestone Project 2 - Solution Code.ipynb | 0 32 files changed, 148 insertions(+), 24 deletions(-) rename {08-Modules and Packages => 06-Modules and Packages}/.ipynb_checkpoints/01-Modules and Packages-checkpoint.ipynb (100%) create mode 100644 06-Modules and Packages/00-Modules_and_Packages/mymodule.py create mode 100644 06-Modules and Packages/00-Modules_and_Packages/myprogram.py create mode 100644 06-Modules and Packages/01-Name_and_Main/Explanation.txt create mode 100644 06-Modules and Packages/01-Name_and_Main/one.py create mode 100644 06-Modules and Packages/01-Name_and_Main/two.py rename 08-Modules and Packages/01-Modules and Packages.ipynb => 06-Modules and Packages/Useful_Info_Notebook.ipynb (100%) rename {06-Errors and Exception Handling => 07-Errors and Exception Handling}/.ipynb_checkpoints/01-Errors and Exceptions Handling-checkpoint.ipynb (100%) rename {06-Errors and Exception Handling => 07-Errors and Exception Handling}/.ipynb_checkpoints/02-Errors and Exceptions Homework-checkpoint.ipynb (100%) rename {06-Errors and Exception Handling => 07-Errors and Exception Handling}/.ipynb_checkpoints/03-Errors and Exceptions Homework - Solution-checkpoint.ipynb (100%) rename {06-Errors and Exception Handling => 07-Errors and Exception Handling}/.ipynb_checkpoints/04-Unit Testing-checkpoint.ipynb (100%) rename {06-Errors and Exception Handling => 07-Errors and Exception Handling}/01-Errors and Exceptions Handling.ipynb (100%) rename {06-Errors and Exception Handling => 07-Errors and Exception Handling}/02-Errors and Exceptions Homework.ipynb (100%) rename {06-Errors and Exception Handling => 07-Errors and Exception Handling}/03-Errors and Exceptions Homework - Solution.ipynb (100%) rename {06-Errors and Exception Handling => 07-Errors and Exception Handling}/04-Unit Testing.ipynb (100%) rename {06-Errors and Exception Handling => 07-Errors and Exception Handling}/__pycache__/cap.cpython-36.pyc (100%) rename {06-Errors and Exception Handling => 07-Errors and Exception Handling}/cap.py (100%) rename {06-Errors and Exception Handling => 07-Errors and Exception Handling}/simple1.py (100%) rename {06-Errors and Exception Handling => 07-Errors and Exception Handling}/simple2.py (100%) rename {06-Errors and Exception Handling => 07-Errors and Exception Handling}/test_cap.py (100%) rename {06-Errors and Exception Handling => 07-Errors and Exception Handling}/testfile (100%) rename {07-Milestone Project - 2 => 08-Milestone Project - 2}/.ipynb_checkpoints/01-Milestone Project 2 - Assignment-checkpoint.ipynb (100%) rename {07-Milestone Project - 2 => 08-Milestone Project - 2}/.ipynb_checkpoints/02-Milestone Project 2 - Walkthrough Steps Workbook-checkpoint.ipynb (100%) rename {07-Milestone Project - 2 => 08-Milestone Project - 2}/.ipynb_checkpoints/03-Milestone Project 2 - Complete Walkthrough Solution-checkpoint.ipynb (100%) rename {07-Milestone Project - 2 => 08-Milestone Project - 2}/.ipynb_checkpoints/04-Milestone Project 2 - Solution Code-checkpoint.ipynb (100%) rename {07-Milestone Project - 2 => 08-Milestone Project - 2}/01-Milestone Project 2 - Assignment.ipynb (100%) rename {07-Milestone Project - 2 => 08-Milestone Project - 2}/02-Milestone Project 2 - Walkthrough Steps Workbook.ipynb (100%) rename {07-Milestone Project - 2 => 08-Milestone Project - 2}/03-Milestone Project 2 - Complete Walkthrough Solution.ipynb (100%) rename {07-Milestone Project - 2 => 08-Milestone Project - 2}/04-Milestone Project 2 - Solution Code.ipynb (100%) diff --git a/03-Methods and Functions/.ipynb_checkpoints/05-Lambda-Expressions-Map-and-Filter-checkpoint.ipynb b/03-Methods and Functions/.ipynb_checkpoints/05-Lambda-Expressions-Map-and-Filter-checkpoint.ipynb index 352fd3d12..4243e6898 100644 --- a/03-Methods and Functions/.ipynb_checkpoints/05-Lambda-Expressions-Map-and-Filter-checkpoint.ipynb +++ b/03-Methods and Functions/.ipynb_checkpoints/05-Lambda-Expressions-Map-and-Filter-checkpoint.ipynb @@ -217,7 +217,7 @@ "source": [ "## lambda expression\n", "\n", - "One of Pythons most useful (and for recruits, confusing) tools is the lambda expression. lambda expressions allow us to create \"anonymous\" functions. This basically means we can quickly make ad-hoc functions without needing to properly define a function using def.\n", + "One of Pythons most useful (and for beginners, confusing) tools is the lambda expression. lambda expressions allow us to create \"anonymous\" functions. This basically means we can quickly make ad-hoc functions without needing to properly define a function using def.\n", "\n", "Function objects returned by running lambda expressions work exactly the same as those created and assigned by defs. There is key difference that makes lambda useful in specialized roles:\n", "\n", diff --git a/03-Methods and Functions/05-Lambda-Expressions-Map-and-Filter.ipynb b/03-Methods and Functions/05-Lambda-Expressions-Map-and-Filter.ipynb index 352fd3d12..4243e6898 100644 --- a/03-Methods and Functions/05-Lambda-Expressions-Map-and-Filter.ipynb +++ b/03-Methods and Functions/05-Lambda-Expressions-Map-and-Filter.ipynb @@ -217,7 +217,7 @@ "source": [ "## lambda expression\n", "\n", - "One of Pythons most useful (and for recruits, confusing) tools is the lambda expression. lambda expressions allow us to create \"anonymous\" functions. This basically means we can quickly make ad-hoc functions without needing to properly define a function using def.\n", + "One of Pythons most useful (and for beginners, confusing) tools is the lambda expression. lambda expressions allow us to create \"anonymous\" functions. This basically means we can quickly make ad-hoc functions without needing to properly define a function using def.\n", "\n", "Function objects returned by running lambda expressions work exactly the same as those created and assigned by defs. There is key difference that makes lambda useful in specialized roles:\n", "\n", diff --git a/04-Milestone Project - 1/03-Milestone Project 1 - Complete Walkthrough Solution.ipynb b/04-Milestone Project - 1/03-Milestone Project 1 - Complete Walkthrough Solution.ipynb index 8e84722d0..cad94aa7e 100644 --- a/04-Milestone Project - 1/03-Milestone Project 1 - Complete Walkthrough Solution.ipynb +++ b/04-Milestone Project - 1/03-Milestone Project 1 - Complete Walkthrough Solution.ipynb @@ -52,9 +52,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -116,9 +114,7 @@ { "cell_type": "code", "execution_count": 4, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -171,9 +167,7 @@ { "cell_type": "code", "execution_count": 6, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -235,9 +229,7 @@ { "cell_type": "code", "execution_count": 8, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -375,27 +367,25 @@ }, { "cell_type": "code", - "execution_count": 16, - "metadata": { - "collapsed": false - }, + "execution_count": 14, + "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " | |\n", - " | O | \n", + " | O | O\n", " | |\n", "-----------\n", " | |\n", - " | O | X\n", + " | | \n", " | |\n", "-----------\n", " | |\n", - " X | O | X\n", + " X | X | X\n", " | |\n", - "Player 2 has won!\n", + "Congratulations! You have won the game!\n", "Do you want to play again? Enter Yes or No: No\n" ] } @@ -473,7 +463,7 @@ "metadata": { "anaconda-cloud": {}, "kernelspec": { - "display_name": "Python [default]", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -487,7 +477,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.3" + "version": "3.6.1" } }, "nbformat": 4, diff --git a/08-Modules and Packages/.ipynb_checkpoints/01-Modules and Packages-checkpoint.ipynb b/06-Modules and Packages/.ipynb_checkpoints/01-Modules and Packages-checkpoint.ipynb similarity index 100% rename from 08-Modules and Packages/.ipynb_checkpoints/01-Modules and Packages-checkpoint.ipynb rename to 06-Modules and Packages/.ipynb_checkpoints/01-Modules and Packages-checkpoint.ipynb diff --git a/06-Modules and Packages/00-Modules_and_Packages/mymodule.py b/06-Modules and Packages/00-Modules_and_Packages/mymodule.py new file mode 100644 index 000000000..6661fd81a --- /dev/null +++ b/06-Modules and Packages/00-Modules_and_Packages/mymodule.py @@ -0,0 +1,5 @@ +# This is the module we will be importing from! +# Great resource: https://docs.python.org/3/tutorial/modules.html + +def func_in_mymodule(): + print("I am a function inside of the mymodule.py file!") diff --git a/06-Modules and Packages/00-Modules_and_Packages/myprogram.py b/06-Modules and Packages/00-Modules_and_Packages/myprogram.py new file mode 100644 index 000000000..20790d389 --- /dev/null +++ b/06-Modules and Packages/00-Modules_and_Packages/myprogram.py @@ -0,0 +1,34 @@ +################ +# Example Three: +################ +# Uncomment this and comment everything else to run! + +# import mymodule +# mymodule.func_in_mymodule() + +################ +# Example Two: +################ +# Uncomment this and comment everything else to run! + +# import mymodule as mm +# mm.func_in_mymodule() + +################ +# Example Three: +################ +# Uncomment this and comment everything else to run! + +# from mymodule import func_in_mymodule +# func_in_mymodule() + +################ +# Example Four: +################ +# Uncomment this and comment everything else to run! + +# This is posisble but frowned upon, often causes poorly readable code because +# you don't know what functions come from mymodule + +# from mymodule import * +# func_in_mymodule() diff --git a/06-Modules and Packages/01-Name_and_Main/Explanation.txt b/06-Modules and Packages/01-Name_and_Main/Explanation.txt new file mode 100644 index 000000000..19eb661e7 --- /dev/null +++ b/06-Modules and Packages/01-Name_and_Main/Explanation.txt @@ -0,0 +1,76 @@ +Sometimes when you are importing from a module, you would like to know whether +a modules function is being used as an import, or if you are using the original +.py file of that module. In this case we can use the: + + if __name__ == "__main__": + +line to determine this. For example: + +When your script is run by passing it as a command to the Python interpreter: + + python myscript.py + +all of the code that is at indentation level 0 gets executed. Functions and +classes that are defined are, well, defined, but none of their code gets ran. +Unlike other languages, there's no main() function that gets run automatically +- the main() function is implicitly all the code at the top level. + +In this case, the top-level code is an if block. __name__ is a built-in variable + which evaluate to the name of the current module. However, if a module is being + run directly (as in myscript.py above), then __name__ instead is set to the + string "__main__". Thus, you can test whether your script is being run directly + or being imported by something else by testing + + if __name__ == "__main__": + ... + +If that code is being imported into another module, the various function and +class definitions will be imported, but the main() code won't get run. As a +basic example, consider the following two scripts: + + # file one.py + def func(): + print("func() in one.py") + + print("top-level in one.py") + + if __name__ == "__main__": + print("one.py is being run directly") + else: + print("one.py is being imported into another module") + +and then: + + # file two.py + import one + + print("top-level in two.py") + one.func() + + if __name__ == "__main__": + print("two.py is being run directly") + else: + print("two.py is being imported into another module") + +Now, if you invoke the interpreter as + + python one.py + +The output will be + + top-level in one.py + +one.py is being run directly +If you run two.py instead: + + python two.py + +You get + + top-level in one.py + one.py is being imported into another module + top-level in two.py + func() in one.py + two.py is being run directly + +Thus, when module one gets loaded, its __name__ equals "one" instead of __main__. diff --git a/06-Modules and Packages/01-Name_and_Main/one.py b/06-Modules and Packages/01-Name_and_Main/one.py new file mode 100644 index 000000000..41818a638 --- /dev/null +++ b/06-Modules and Packages/01-Name_and_Main/one.py @@ -0,0 +1,9 @@ +def func(): + print("func() ran in one.py") + +print("top-level print inside of one.py") + +if __name__ == "__main__": + print("one.py is being run directly") +else: + print("one.py is being imported into another module") diff --git a/06-Modules and Packages/01-Name_and_Main/two.py b/06-Modules and Packages/01-Name_and_Main/two.py new file mode 100644 index 000000000..ec630497d --- /dev/null +++ b/06-Modules and Packages/01-Name_and_Main/two.py @@ -0,0 +1,10 @@ +import one + +print("top-level in two.py") + +one.func() + +if __name__ == "__main__": + print("two.py is being run directly") +else: + print("two.py is being imported into another module") diff --git a/08-Modules and Packages/01-Modules and Packages.ipynb b/06-Modules and Packages/Useful_Info_Notebook.ipynb similarity index 100% rename from 08-Modules and Packages/01-Modules and Packages.ipynb rename to 06-Modules and Packages/Useful_Info_Notebook.ipynb diff --git a/06-Errors and Exception Handling/.ipynb_checkpoints/01-Errors and Exceptions Handling-checkpoint.ipynb b/07-Errors and Exception Handling/.ipynb_checkpoints/01-Errors and Exceptions Handling-checkpoint.ipynb similarity index 100% rename from 06-Errors and Exception Handling/.ipynb_checkpoints/01-Errors and Exceptions Handling-checkpoint.ipynb rename to 07-Errors and Exception Handling/.ipynb_checkpoints/01-Errors and Exceptions Handling-checkpoint.ipynb diff --git a/06-Errors and Exception Handling/.ipynb_checkpoints/02-Errors and Exceptions Homework-checkpoint.ipynb b/07-Errors and Exception Handling/.ipynb_checkpoints/02-Errors and Exceptions Homework-checkpoint.ipynb similarity index 100% rename from 06-Errors and Exception Handling/.ipynb_checkpoints/02-Errors and Exceptions Homework-checkpoint.ipynb rename to 07-Errors and Exception Handling/.ipynb_checkpoints/02-Errors and Exceptions Homework-checkpoint.ipynb diff --git a/06-Errors and Exception Handling/.ipynb_checkpoints/03-Errors and Exceptions Homework - Solution-checkpoint.ipynb b/07-Errors and Exception Handling/.ipynb_checkpoints/03-Errors and Exceptions Homework - Solution-checkpoint.ipynb similarity index 100% rename from 06-Errors and Exception Handling/.ipynb_checkpoints/03-Errors and Exceptions Homework - Solution-checkpoint.ipynb rename to 07-Errors and Exception Handling/.ipynb_checkpoints/03-Errors and Exceptions Homework - Solution-checkpoint.ipynb diff --git a/06-Errors and Exception Handling/.ipynb_checkpoints/04-Unit Testing-checkpoint.ipynb b/07-Errors and Exception Handling/.ipynb_checkpoints/04-Unit Testing-checkpoint.ipynb similarity index 100% rename from 06-Errors and Exception Handling/.ipynb_checkpoints/04-Unit Testing-checkpoint.ipynb rename to 07-Errors and Exception Handling/.ipynb_checkpoints/04-Unit Testing-checkpoint.ipynb diff --git a/06-Errors and Exception Handling/01-Errors and Exceptions Handling.ipynb b/07-Errors and Exception Handling/01-Errors and Exceptions Handling.ipynb similarity index 100% rename from 06-Errors and Exception Handling/01-Errors and Exceptions Handling.ipynb rename to 07-Errors and Exception Handling/01-Errors and Exceptions Handling.ipynb diff --git a/06-Errors and Exception Handling/02-Errors and Exceptions Homework.ipynb b/07-Errors and Exception Handling/02-Errors and Exceptions Homework.ipynb similarity index 100% rename from 06-Errors and Exception Handling/02-Errors and Exceptions Homework.ipynb rename to 07-Errors and Exception Handling/02-Errors and Exceptions Homework.ipynb diff --git a/06-Errors and Exception Handling/03-Errors and Exceptions Homework - Solution.ipynb b/07-Errors and Exception Handling/03-Errors and Exceptions Homework - Solution.ipynb similarity index 100% rename from 06-Errors and Exception Handling/03-Errors and Exceptions Homework - Solution.ipynb rename to 07-Errors and Exception Handling/03-Errors and Exceptions Homework - Solution.ipynb diff --git a/06-Errors and Exception Handling/04-Unit Testing.ipynb b/07-Errors and Exception Handling/04-Unit Testing.ipynb similarity index 100% rename from 06-Errors and Exception Handling/04-Unit Testing.ipynb rename to 07-Errors and Exception Handling/04-Unit Testing.ipynb diff --git a/06-Errors and Exception Handling/__pycache__/cap.cpython-36.pyc b/07-Errors and Exception Handling/__pycache__/cap.cpython-36.pyc similarity index 100% rename from 06-Errors and Exception Handling/__pycache__/cap.cpython-36.pyc rename to 07-Errors and Exception Handling/__pycache__/cap.cpython-36.pyc diff --git a/06-Errors and Exception Handling/cap.py b/07-Errors and Exception Handling/cap.py similarity index 100% rename from 06-Errors and Exception Handling/cap.py rename to 07-Errors and Exception Handling/cap.py diff --git a/06-Errors and Exception Handling/simple1.py b/07-Errors and Exception Handling/simple1.py similarity index 100% rename from 06-Errors and Exception Handling/simple1.py rename to 07-Errors and Exception Handling/simple1.py diff --git a/06-Errors and Exception Handling/simple2.py b/07-Errors and Exception Handling/simple2.py similarity index 100% rename from 06-Errors and Exception Handling/simple2.py rename to 07-Errors and Exception Handling/simple2.py diff --git a/06-Errors and Exception Handling/test_cap.py b/07-Errors and Exception Handling/test_cap.py similarity index 100% rename from 06-Errors and Exception Handling/test_cap.py rename to 07-Errors and Exception Handling/test_cap.py diff --git a/06-Errors and Exception Handling/testfile b/07-Errors and Exception Handling/testfile similarity index 100% rename from 06-Errors and Exception Handling/testfile rename to 07-Errors and Exception Handling/testfile diff --git a/07-Milestone Project - 2/.ipynb_checkpoints/01-Milestone Project 2 - Assignment-checkpoint.ipynb b/08-Milestone Project - 2/.ipynb_checkpoints/01-Milestone Project 2 - Assignment-checkpoint.ipynb similarity index 100% rename from 07-Milestone Project - 2/.ipynb_checkpoints/01-Milestone Project 2 - Assignment-checkpoint.ipynb rename to 08-Milestone Project - 2/.ipynb_checkpoints/01-Milestone Project 2 - Assignment-checkpoint.ipynb diff --git a/07-Milestone Project - 2/.ipynb_checkpoints/02-Milestone Project 2 - Walkthrough Steps Workbook-checkpoint.ipynb b/08-Milestone Project - 2/.ipynb_checkpoints/02-Milestone Project 2 - Walkthrough Steps Workbook-checkpoint.ipynb similarity index 100% rename from 07-Milestone Project - 2/.ipynb_checkpoints/02-Milestone Project 2 - Walkthrough Steps Workbook-checkpoint.ipynb rename to 08-Milestone Project - 2/.ipynb_checkpoints/02-Milestone Project 2 - Walkthrough Steps Workbook-checkpoint.ipynb diff --git a/07-Milestone Project - 2/.ipynb_checkpoints/03-Milestone Project 2 - Complete Walkthrough Solution-checkpoint.ipynb b/08-Milestone Project - 2/.ipynb_checkpoints/03-Milestone Project 2 - Complete Walkthrough Solution-checkpoint.ipynb similarity index 100% rename from 07-Milestone Project - 2/.ipynb_checkpoints/03-Milestone Project 2 - Complete Walkthrough Solution-checkpoint.ipynb rename to 08-Milestone Project - 2/.ipynb_checkpoints/03-Milestone Project 2 - Complete Walkthrough Solution-checkpoint.ipynb diff --git a/07-Milestone Project - 2/.ipynb_checkpoints/04-Milestone Project 2 - Solution Code-checkpoint.ipynb b/08-Milestone Project - 2/.ipynb_checkpoints/04-Milestone Project 2 - Solution Code-checkpoint.ipynb similarity index 100% rename from 07-Milestone Project - 2/.ipynb_checkpoints/04-Milestone Project 2 - Solution Code-checkpoint.ipynb rename to 08-Milestone Project - 2/.ipynb_checkpoints/04-Milestone Project 2 - Solution Code-checkpoint.ipynb diff --git a/07-Milestone Project - 2/01-Milestone Project 2 - Assignment.ipynb b/08-Milestone Project - 2/01-Milestone Project 2 - Assignment.ipynb similarity index 100% rename from 07-Milestone Project - 2/01-Milestone Project 2 - Assignment.ipynb rename to 08-Milestone Project - 2/01-Milestone Project 2 - Assignment.ipynb diff --git a/07-Milestone Project - 2/02-Milestone Project 2 - Walkthrough Steps Workbook.ipynb b/08-Milestone Project - 2/02-Milestone Project 2 - Walkthrough Steps Workbook.ipynb similarity index 100% rename from 07-Milestone Project - 2/02-Milestone Project 2 - Walkthrough Steps Workbook.ipynb rename to 08-Milestone Project - 2/02-Milestone Project 2 - Walkthrough Steps Workbook.ipynb diff --git a/07-Milestone Project - 2/03-Milestone Project 2 - Complete Walkthrough Solution.ipynb b/08-Milestone Project - 2/03-Milestone Project 2 - Complete Walkthrough Solution.ipynb similarity index 100% rename from 07-Milestone Project - 2/03-Milestone Project 2 - Complete Walkthrough Solution.ipynb rename to 08-Milestone Project - 2/03-Milestone Project 2 - Complete Walkthrough Solution.ipynb diff --git a/07-Milestone Project - 2/04-Milestone Project 2 - Solution Code.ipynb b/08-Milestone Project - 2/04-Milestone Project 2 - Solution Code.ipynb similarity index 100% rename from 07-Milestone Project - 2/04-Milestone Project 2 - Solution Code.ipynb rename to 08-Milestone Project - 2/04-Milestone Project 2 - Solution Code.ipynb From 72797a621403272c2e79439a59d6b8fe0c2df573 Mon Sep 17 00:00:00 2001 From: Jose Windows Date: Sun, 25 Feb 2018 22:39:13 -0800 Subject: [PATCH 2/2] reorder --- .../MyMainPackage/SubPackage/__init__.py | 0 .../__pycache__/__init__.cpython-36.pyc | Bin 0 -> 144 bytes .../__pycache__/mysubscript.cpython-36.pyc | Bin 0 -> 293 bytes .../MyMainPackage/SubPackage/mysubscript.py | 2 + .../MyMainPackage/__init__.py | 0 .../__pycache__/__init__.cpython-36.pyc | Bin 0 -> 133 bytes .../some_main_script.cpython-36.pyc | Bin 0 -> 297 bytes .../MyMainPackage/some_main_script.py | 2 + .../00-Modules_and_Packages/mymodule.py | 7 +--- .../00-Modules_and_Packages/myprogram.py | 36 ++---------------- 10 files changed, 10 insertions(+), 37 deletions(-) create mode 100644 06-Modules and Packages/00-Modules_and_Packages/MyMainPackage/SubPackage/__init__.py create mode 100644 06-Modules and Packages/00-Modules_and_Packages/MyMainPackage/SubPackage/__pycache__/__init__.cpython-36.pyc create mode 100644 06-Modules and Packages/00-Modules_and_Packages/MyMainPackage/SubPackage/__pycache__/mysubscript.cpython-36.pyc create mode 100644 06-Modules and Packages/00-Modules_and_Packages/MyMainPackage/SubPackage/mysubscript.py create mode 100644 06-Modules and Packages/00-Modules_and_Packages/MyMainPackage/__init__.py create mode 100644 06-Modules and Packages/00-Modules_and_Packages/MyMainPackage/__pycache__/__init__.cpython-36.pyc create mode 100644 06-Modules and Packages/00-Modules_and_Packages/MyMainPackage/__pycache__/some_main_script.cpython-36.pyc create mode 100644 06-Modules and Packages/00-Modules_and_Packages/MyMainPackage/some_main_script.py diff --git a/06-Modules and Packages/00-Modules_and_Packages/MyMainPackage/SubPackage/__init__.py b/06-Modules and Packages/00-Modules_and_Packages/MyMainPackage/SubPackage/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/06-Modules and Packages/00-Modules_and_Packages/MyMainPackage/SubPackage/__pycache__/__init__.cpython-36.pyc b/06-Modules and Packages/00-Modules_and_Packages/MyMainPackage/SubPackage/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d4fedf2cad189c931116e388bc72216034cd7e4c GIT binary patch literal 144 zcmXr!<>i`le_|8^5IhDEFu(|8H~?`m3y?@*2xib^^jpbL1QJFNzigeYVnT~ki;81> z6N{2F6LVr*Qj4=o@(W^oD}56)^8yl+vlG)(V}eVQV9faV%)HE!_;|g7%3B;Zx%nxj NIjMFaV~c^90RW`QBy|7) literal 0 HcmV?d00001 diff --git a/06-Modules and Packages/00-Modules_and_Packages/MyMainPackage/SubPackage/__pycache__/mysubscript.cpython-36.pyc b/06-Modules and Packages/00-Modules_and_Packages/MyMainPackage/SubPackage/__pycache__/mysubscript.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..24a8ba48356a465d2f11d3f1878c19c2f287543d GIT binary patch literal 293 zcmXr!<>g{}Ffq!Jfq~&M5W@izkmUfx#XLYFg&~Epg&~R|g(;XplQ|hE0tX;<&Oi)S zR{~Vm%*Y5-4^+qGSEb^STB+cftB|OWR+^Vwl9`{UkeOGUnUboITUlJ1RGeItSx}IL0@zC^<7RC&neUIJ+djAjY@SH!(9WATc>R zF+DXVxHJjIL^4yapz;1M3250su4cM2r9c literal 0 HcmV?d00001 diff --git a/06-Modules and Packages/00-Modules_and_Packages/MyMainPackage/SubPackage/mysubscript.py b/06-Modules and Packages/00-Modules_and_Packages/MyMainPackage/SubPackage/mysubscript.py new file mode 100644 index 000000000..0c4217ffe --- /dev/null +++ b/06-Modules and Packages/00-Modules_and_Packages/MyMainPackage/SubPackage/mysubscript.py @@ -0,0 +1,2 @@ +def sub_report(): + print("Hey Im a function inside mysubscript") \ No newline at end of file diff --git a/06-Modules and Packages/00-Modules_and_Packages/MyMainPackage/__init__.py b/06-Modules and Packages/00-Modules_and_Packages/MyMainPackage/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/06-Modules and Packages/00-Modules_and_Packages/MyMainPackage/__pycache__/__init__.cpython-36.pyc b/06-Modules and Packages/00-Modules_and_Packages/MyMainPackage/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..36ec225ce2c1367e1aa03ea64e26c5d18c5a4b55 GIT binary patch literal 133 zcmXr!<>hL-KQW2{2p)q77+?f49Dul(1xTbY1T$zd`mJOr0tq9CUq;SWF`>n&Ma40` ziABkoi8(PYsm0kP`2{h)mA;9Yc>#&Z*@@|?G4b)4d6^~g@p=W7w>WHa^HWN5Qtd!y I6$3E?0Q-?3A^-pY literal 0 HcmV?d00001 diff --git a/06-Modules and Packages/00-Modules_and_Packages/MyMainPackage/__pycache__/some_main_script.cpython-36.pyc b/06-Modules and Packages/00-Modules_and_Packages/MyMainPackage/__pycache__/some_main_script.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c0b08646ad574c489c475a84c7e1e3e56c5dcd4b GIT binary patch literal 297 zcmXr!<>iuoFfq!Tfq~&M5W@izkmUfx#XLYFg&~Epg&~R|g(;XplQ|hE0tX;<&Oi)S zR{~Vm%*Y5-4^+qGSEcKbTB+cvkeI8GnWs>kpPL$=o0ypwUz}W&Sx^EJ1924!5|gtN z(^K^{8E>%`6lLa>tYjzx84D(USvgz9gche37037{7A0pU=ES(97H5~_7sU8h`U15F zKy=5T8?RSTd5gO!wIIK!1Z*oK$dMpp85oOLfTW)$ghp5eVKD>cZgJS;=BJeAq}qXX HfiwXCH_$~@ literal 0 HcmV?d00001 diff --git a/06-Modules and Packages/00-Modules_and_Packages/MyMainPackage/some_main_script.py b/06-Modules and Packages/00-Modules_and_Packages/MyMainPackage/some_main_script.py new file mode 100644 index 000000000..b1c7287ac --- /dev/null +++ b/06-Modules and Packages/00-Modules_and_Packages/MyMainPackage/some_main_script.py @@ -0,0 +1,2 @@ +def report_main(): + print("Hey I am in some_main_script in main package.") \ No newline at end of file diff --git a/06-Modules and Packages/00-Modules_and_Packages/mymodule.py b/06-Modules and Packages/00-Modules_and_Packages/mymodule.py index 6661fd81a..5970453b8 100644 --- a/06-Modules and Packages/00-Modules_and_Packages/mymodule.py +++ b/06-Modules and Packages/00-Modules_and_Packages/mymodule.py @@ -1,5 +1,2 @@ -# This is the module we will be importing from! -# Great resource: https://docs.python.org/3/tutorial/modules.html - -def func_in_mymodule(): - print("I am a function inside of the mymodule.py file!") +def my_func(): + print("Hey I am in mymodule.py") \ No newline at end of file diff --git a/06-Modules and Packages/00-Modules_and_Packages/myprogram.py b/06-Modules and Packages/00-Modules_and_Packages/myprogram.py index 20790d389..e08a2cb0d 100644 --- a/06-Modules and Packages/00-Modules_and_Packages/myprogram.py +++ b/06-Modules and Packages/00-Modules_and_Packages/myprogram.py @@ -1,34 +1,6 @@ -################ -# Example Three: -################ -# Uncomment this and comment everything else to run! +from MyMainPackage.some_main_script import report_main +from MyMainPackage.SubPackage import mysubscript -# import mymodule -# mymodule.func_in_mymodule() +report_main() -################ -# Example Two: -################ -# Uncomment this and comment everything else to run! - -# import mymodule as mm -# mm.func_in_mymodule() - -################ -# Example Three: -################ -# Uncomment this and comment everything else to run! - -# from mymodule import func_in_mymodule -# func_in_mymodule() - -################ -# Example Four: -################ -# Uncomment this and comment everything else to run! - -# This is posisble but frowned upon, often causes poorly readable code because -# you don't know what functions come from mymodule - -# from mymodule import * -# func_in_mymodule() +mysubscript.sub_report()