title
Python Tutorial for Beginners 9: Import Modules and Exploring The Standard Library
description
In this Python Beginner Tutorial, we will begin learning how to import modules in Python. We will learn how to import modules we have written, as well as modules from the Standard Library. We will also explore sys.path and how imported modules are found. Let's get started.
The code from this video can be found at:
https://github.com/CoreyMSchafer/code_snippets/tree/master/Python-Imports
Watch the full Python Beginner Series here:
https://www.youtube.com/playlist?list=PL-osiE80TeTskrapNbzXhwoFUiLCjGgY7
✅ Support My Channel Through Patreon:
https://www.patreon.com/coreyms
✅ Become a Channel Member:
https://www.youtube.com/channel/UCCezIgC97PvUuR4_gbFUs5g/join
✅ One-Time Contribution Through PayPal:
https://goo.gl/649HFY
✅ Cryptocurrency Donations:
Bitcoin Wallet - 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet - 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet - MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot
✅ Corey's Public Amazon Wishlist
http://a.co/inIyro1
✅ Equipment I Use and Books I Recommend:
https://www.amazon.com/shop/coreyschafer
▶️ You Can Find Me On:
My Website - http://coreyms.com/
My Second Channel - https://www.youtube.com/c/coreymschafer
Facebook - https://www.facebook.com/CoreyMSchafer
Twitter - https://twitter.com/CoreyMSchafer
Instagram - https://www.instagram.com/coreymschafer/
#Python
detail
{'title': 'Python Tutorial for Beginners 9: Import Modules and Exploring The Standard Library', 'heatmap': [{'end': 138.418, 'start': 34.263, 'weight': 0.989}, {'end': 426.873, 'start': 377.52, 'weight': 0.802}, {'end': 594.388, 'start': 579.682, 'weight': 0.737}, {'end': 727.505, 'start': 711.316, 'weight': 0.783}, {'end': 1148.961, 'start': 1079.662, 'weight': 0.708}, {'end': 1186.855, 'start': 1172.067, 'weight': 0.943}], 'summary': "Tutorial covers the process of importing modules in python, including how to import modules, use functions from them, specify aliases, mitigate risks of 'import star', set python path to avoid 'module not found' errors, and explore the python standard library's benefits and specific modules like math, datetime, calendar, and os to solve common problems.", 'chapters': [{'end': 312.523, 'segs': [{'end': 29.579, 'src': 'embed', 'start': 0.209, 'weight': 0, 'content': [{'end': 3.794, 'text': "Hey there, how's it going everybody? In this video, we'll be learning how to import modules.", 'start': 0.209, 'duration': 3.585}, {'end': 11.845, 'text': "We'll start by importing modules that we've written and then we'll explore a bit of the standard library and how we can import those modules to solve a lot of common problems.", 'start': 4.115, 'duration': 7.73}, {'end': 14.609, 'text': 'So I have a module here called mymodule.py.', 'start': 12.226, 'duration': 2.383}, {'end': 20.213, 'text': "Now, within this module, we have a print statement, and we'll talk about that in just a minute.", 'start': 15.57, 'duration': 4.643}, {'end': 26.497, 'text': 'We also have this test variable set to test string, and then we have this function called find index.', 'start': 20.654, 'duration': 5.843}, {'end': 29.579, 'text': 'And this find index function takes in two arguments.', 'start': 26.918, 'duration': 2.661}], 'summary': 'Learning to import modules for solving common problems in python.', 'duration': 29.37, 'max_score': 0.209, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CqvZ3vGoGs0/pics/CqvZ3vGoGs0209.jpg'}, {'end': 58.52, 'src': 'embed', 'start': 34.263, 'weight': 1, 'content': [{'end': 42.248, 'text': 'And we can see that we have some documentation here that just says that this finds the index of a value in a sequence, and then it returns that index.', 'start': 34.263, 'duration': 7.985}, {'end': 45.67, 'text': "But if it doesn't find that value, then it just returns negative one.", 'start': 42.588, 'duration': 3.082}, {'end': 50.434, 'text': "So let's say that we wrote this function and that we want to use this in other modules or scripts.", 'start': 46.071, 'duration': 4.363}, {'end': 52.856, 'text': "So what we're going to want to do is import this.", 'start': 50.754, 'duration': 2.102}, {'end': 58.52, 'text': "So I have another module over here, which is just our intro.py file that we've been working with.", 'start': 53.196, 'duration': 5.324}], 'summary': 'The function finds index of a value in a sequence and returns it, or -1 if not found.', 'duration': 24.257, 'max_score': 34.263, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CqvZ3vGoGs0/pics/CqvZ3vGoGs034263.jpg'}, {'end': 138.418, 'src': 'heatmap', 'start': 34.263, 'weight': 0.989, 'content': [{'end': 42.248, 'text': 'And we can see that we have some documentation here that just says that this finds the index of a value in a sequence, and then it returns that index.', 'start': 34.263, 'duration': 7.985}, {'end': 45.67, 'text': "But if it doesn't find that value, then it just returns negative one.", 'start': 42.588, 'duration': 3.082}, {'end': 50.434, 'text': "So let's say that we wrote this function and that we want to use this in other modules or scripts.", 'start': 46.071, 'duration': 4.363}, {'end': 52.856, 'text': "So what we're going to want to do is import this.", 'start': 50.754, 'duration': 2.102}, {'end': 58.52, 'text': "So I have another module over here, which is just our intro.py file that we've been working with.", 'start': 53.196, 'duration': 5.324}, {'end': 63.561, 'text': 'Now, within this file, we have this courses variable that is just a list of course names.', 'start': 58.88, 'duration': 4.681}, {'end': 68.042, 'text': "So let's say that we want to use that find index function from my module.", 'start': 63.901, 'duration': 4.141}, {'end': 73.563, 'text': 'Now, I actually created this my module in the same directory as my intro.py.', 'start': 68.382, 'duration': 5.181}, {'end': 76.703, 'text': "So that means that we're going to be able to directly import that.", 'start': 73.863, 'duration': 2.84}, {'end': 81.924, 'text': 'Now, when we import a file, it actually runs all of the code from the module that we import.', 'start': 77.083, 'duration': 4.841}, {'end': 84.865, 'text': "So that's how it creates all the functions and variables.", 'start': 82.184, 'duration': 2.681}, {'end': 90.346, 'text': 'But if we have any other code like print statements or anything like that, then that will be run as well.', 'start': 85.185, 'duration': 5.161}, {'end': 95.468, 'text': "So that's why I have the print statement here in my module so that we can see when that happens.", 'start': 90.747, 'duration': 4.721}, {'end': 101.83, 'text': 'So to import this module, we can just come to the top of the file here and say, import my module.', 'start': 95.908, 'duration': 5.922}, {'end': 107.615, 'text': "And again, we can import that directly because it's in the same directory as our intro.py file.", 'start': 102.09, 'duration': 5.525}, {'end': 110.197, 'text': 'and now, if we run this with this import,', 'start': 107.615, 'duration': 2.582}, {'end': 116.063, 'text': 'then we can see that it imported successfully because it printed out that print statement within that module.', 'start': 110.197, 'duration': 5.866}, {'end': 119.427, 'text': "okay, so let's say that we want to use that find index function.", 'start': 116.063, 'duration': 3.364}, {'end': 124.171, 'text': "now, when importing modules like this, we just can't call our find index function.", 'start': 119.427, 'duration': 4.744}, {'end': 129.634, 'text': 'we instead have to type the module name first and then what we want to grab from that module.', 'start': 124.171, 'duration': 5.463}, {'end': 138.418, 'text': "So if we wanted to use that, then we could say, let's say index is equal to my module dot find index.", 'start': 129.995, 'duration': 8.423}], 'summary': "Importing and using a 'find index' function from a module in python.", 'duration': 104.155, 'max_score': 34.263, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CqvZ3vGoGs0/pics/CqvZ3vGoGs034263.jpg'}, {'end': 101.83, 'src': 'embed', 'start': 73.863, 'weight': 2, 'content': [{'end': 76.703, 'text': "So that means that we're going to be able to directly import that.", 'start': 73.863, 'duration': 2.84}, {'end': 81.924, 'text': 'Now, when we import a file, it actually runs all of the code from the module that we import.', 'start': 77.083, 'duration': 4.841}, {'end': 84.865, 'text': "So that's how it creates all the functions and variables.", 'start': 82.184, 'duration': 2.681}, {'end': 90.346, 'text': 'But if we have any other code like print statements or anything like that, then that will be run as well.', 'start': 85.185, 'duration': 5.161}, {'end': 95.468, 'text': "So that's why I have the print statement here in my module so that we can see when that happens.", 'start': 90.747, 'duration': 4.721}, {'end': 101.83, 'text': 'So to import this module, we can just come to the top of the file here and say, import my module.', 'start': 95.908, 'duration': 5.922}], 'summary': 'Importing a module runs its code, including functions and print statements.', 'duration': 27.967, 'max_score': 73.863, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CqvZ3vGoGs0/pics/CqvZ3vGoGs073863.jpg'}], 'start': 0.209, 'title': 'Importing modules in python', 'summary': 'Covers the process of importing modules in python, including how to import modules, use functions from imported modules, and specify aliases for imported modules, enabling efficient use of the standard library to solve common problems.', 'chapters': [{'end': 312.523, 'start': 0.209, 'title': 'Importing modules in python', 'summary': 'Covers the process of importing modules in python, including how to import modules, use functions from imported modules, and specify aliases for imported modules, enabling efficient use of the standard library to solve common problems.', 'duration': 312.314, 'highlights': ['The chapter covers the process of importing modules in Python, including how to import modules, use functions from imported modules, and specify aliases for imported modules. It provides an overview of the main focus of the chapter, highlighting the key topics covered.', "The find index function in the module mymodule.py returns the index of a value in a sequence, and if it doesn't find the value, it returns -1. Describes the functionality of the find index function and its return values, providing a clear understanding of its purpose.", 'Importing modules involves running all the code from the module being imported, including functions, variables, and print statements. Explains the process of importing modules and the consequent execution of all code within the module, including functions, variables, and print statements.']}], 'duration': 312.314, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CqvZ3vGoGs0/pics/CqvZ3vGoGs0209.jpg', 'highlights': ['The chapter covers the process of importing modules in Python, including how to import modules, use functions from imported modules, and specify aliases for imported modules. It provides an overview of the main focus of the chapter, highlighting the key topics covered.', "The find index function in the module mymodule.py returns the index of a value in a sequence, and if it doesn't find the value, it returns -1. Describes the functionality of the find index function and its return values, providing a clear understanding of its purpose.", 'Importing modules involves running all the code from the module being imported, including functions, variables, and print statements. Explains the process of importing modules and the consequent execution of all code within the module, including functions, variables, and print statements.']}, {'end': 470.957, 'segs': [{'end': 338.317, 'src': 'embed', 'start': 312.944, 'weight': 2, 'content': [{'end': 318.805, 'text': "Now using this method of importing, we'd have to add commas and specify each value that we want to import.", 'start': 312.944, 'duration': 5.861}, {'end': 322.888, 'text': "Now, there is a way to just import everything and I'll show you how to do this.", 'start': 319.185, 'duration': 3.703}, {'end': 326.61, 'text': "But I have to be honest, I never use this and it's pretty frowned upon.", 'start': 323.208, 'duration': 3.402}, {'end': 328.611, 'text': "And we'll see why that is.", 'start': 327.31, 'duration': 1.301}, {'end': 334.615, 'text': 'But if we wanted to just import everything, then we could say from my module, import star.', 'start': 328.911, 'duration': 5.704}, {'end': 338.317, 'text': 'So if we run this, then we can see that everything still works.', 'start': 335.015, 'duration': 3.302}], 'summary': "Method to import all values using 'from my module import star' demonstrated, despite being frowned upon.", 'duration': 25.373, 'max_score': 312.944, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CqvZ3vGoGs0/pics/CqvZ3vGoGs0312944.jpg'}, {'end': 442.956, 'src': 'heatmap', 'start': 377.52, 'weight': 1, 'content': [{'end': 382.441, 'text': "so we didn't pass in a file path or tell Python where to find this module, it just found it.", 'start': 377.52, 'duration': 4.921}, {'end': 387.743, 'text': 'so the way that this works is that when we import a module, it checks multiple locations,', 'start': 382.441, 'duration': 5.302}, {'end': 396.806, 'text': 'and the locations that it checks is within a list called sys.path, and we can actually see this list if we import the sys module.', 'start': 387.743, 'duration': 9.063}, {'end': 401.708, 'text': "so I'll import sys And now down here we'll comment out these two print statements", 'start': 396.806, 'duration': 4.902}, {'end': 406.509, 'text': "And now let's print out that sys.path and run that.", 'start': 402.188, 'duration': 4.321}, {'end': 413.21, 'text': 'So this is the list of directories on my machine where Python looks for modules when we run an import.', 'start': 406.869, 'duration': 6.341}, {'end': 414.99, 'text': 'And it looks in this order.', 'start': 413.33, 'duration': 1.66}, {'end': 421.372, 'text': "Now this first value here is just the directory where I'm currently running the script from.", 'start': 415.39, 'duration': 5.982}, {'end': 426.873, 'text': 'And the my module Python file that we were importing is within that directory also.', 'start': 421.712, 'duration': 5.161}, {'end': 427.993, 'text': "So that's how it found it.", 'start': 427.033, 'duration': 0.96}, {'end': 434.134, 'text': 'Okay, so what directories are added to this sys.path list? So directories get added in this order.', 'start': 428.453, 'duration': 5.681}, {'end': 437.575, 'text': "First, the directory containing the script that we're running.", 'start': 434.594, 'duration': 2.981}, {'end': 442.956, 'text': "So that is why this directory where we're running the script is the first value in sys.path.", 'start': 437.915, 'duration': 5.041}], 'summary': "Python's module import system searches directories in sys.path to find modules, with the script's directory being the first in the search order.", 'duration': 65.436, 'max_score': 377.52, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CqvZ3vGoGs0/pics/CqvZ3vGoGs0377520.jpg'}, {'end': 478.821, 'src': 'embed', 'start': 455.119, 'weight': 0, 'content': [{'end': 464.073, 'text': "And then after the Python path, It then adds the standard library directories, and that's how we can import those modules from the standard library.", 'start': 455.119, 'duration': 8.954}, {'end': 469.656, 'text': 'And lastly, it adds the site packages directory for third-party packages.', 'start': 464.453, 'duration': 5.203}, {'end': 470.957, 'text': "And we'll look at all of these.", 'start': 469.856, 'duration': 1.101}, {'end': 478.821, 'text': "So first let's see what it looks like when the module that we want to import isn't in the same directory as the script that we're trying to import it from.", 'start': 471.357, 'duration': 7.464}], 'summary': 'Python path includes standard library and site packages for module imports.', 'duration': 23.702, 'max_score': 455.119, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CqvZ3vGoGs0/pics/CqvZ3vGoGs0455119.jpg'}], 'start': 312.944, 'title': 'Python module importing', 'summary': "Discusses methods of importing modules in python, addressing risks of 'import star' and explaining python's module location process through sys.path, python path environment variable, standard library directories, and site packages directory.", 'chapters': [{'end': 470.957, 'start': 312.944, 'title': 'Python module importing', 'summary': "Discusses the methods of importing modules in python, highlighting the risks and best practices of using 'import star' and explaining how python locates modules through sys.path list, python path environment variable, standard library directories, and site packages directory.", 'duration': 158.013, 'highlights': ['Python locates modules through sys.path list, Python path environment variable, standard library directories, and site packages directory. Python uses the sys.path list to check multiple locations for importing modules, including the directory where the script is running, directories listed in the Python path environment variable, standard library directories, and site packages directory.', "Risks and best practices of using 'import star' are discussed. The method of importing everything with 'import star' is frowned upon as it makes it harder to track down problems and determine the origin of imported functions or variables.", 'The directory containing the script being run is the first value in sys.path list. The directory where the script is running is the first location checked by Python for importing modules, allowing for easy access to modules from the same directory.']}], 'duration': 158.013, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CqvZ3vGoGs0/pics/CqvZ3vGoGs0312944.jpg', 'highlights': ['Python locates modules through sys.path list, Python path environment variable, standard library directories, and site packages directory.', 'The directory containing the script being run is the first value in sys.path list.', "Risks and best practices of using 'import star' are discussed."]}, {'end': 669.832, 'segs': [{'end': 530.712, 'src': 'embed', 'start': 486.105, 'weight': 0, 'content': [{'end': 495.73, 'text': "So I've got finder pulled up here, and I'm just going to drag this my module over here into this my modules directory that is on my desktop.", 'start': 486.105, 'duration': 9.625}, {'end': 500.933, 'text': "So now that module that we're trying to import is in a completely different location on our machine.", 'start': 496.03, 'duration': 4.903}, {'end': 510.438, 'text': 'So if we go back to here to our script, and now try to run this, then we can see that we get this error module not found no module named my module.', 'start': 501.293, 'duration': 9.145}, {'end': 512.84, 'text': 'Now there are a couple of approaches that we can take here.', 'start': 510.778, 'duration': 2.062}, {'end': 518.043, 'text': 'First is that we can actually manually add that directory to our sys.path list.', 'start': 513.26, 'duration': 4.783}, {'end': 523.947, 'text': "So this sys.path is a list just like any other that we've been looking at, and we can treat it like one.", 'start': 518.524, 'duration': 5.423}, {'end': 530.712, 'text': 'So before we try to import my module, we could add that directory to sys.path.', 'start': 524.348, 'duration': 6.364}], 'summary': 'Struggling with module import error, solved by adding directory to sys.path.', 'duration': 44.607, 'max_score': 486.105, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CqvZ3vGoGs0/pics/CqvZ3vGoGs0486105.jpg'}, {'end': 606.532, 'src': 'heatmap', 'start': 579.682, 'weight': 2, 'content': [{'end': 584.404, 'text': 'So instead we can make this change in the next place sys.path looks.', 'start': 579.682, 'duration': 4.722}, {'end': 588.165, 'text': 'And if we remember, that is the Python path environment variable.', 'start': 584.764, 'duration': 3.401}, {'end': 591.807, 'text': 'Now changing the environment variables is different on Mac and Windows.', 'start': 588.525, 'duration': 3.282}, {'end': 594.388, 'text': "So we'll show how to do this on both really quick.", 'start': 592.107, 'duration': 2.281}, {'end': 597.068, 'text': "So first, we'll see how to do this on a Mac.", 'start': 594.728, 'duration': 2.34}, {'end': 599.389, 'text': "And to do this, I'm going to pull up my terminal.", 'start': 597.449, 'duration': 1.94}, {'end': 606.532, 'text': 'And we can set environment variables by adding them to the dot bash underscore profile file in our home directory.', 'start': 599.649, 'duration': 6.883}], 'summary': 'Demonstrating how to change python path environment variable on mac and windows.', 'duration': 26.85, 'max_score': 579.682, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CqvZ3vGoGs0/pics/CqvZ3vGoGs0579682.jpg'}], 'start': 471.357, 'title': 'Importing and setting python path for modules', 'summary': "Covers importing modules from different directories, highlighting the 'module not found' error and setting python path for importing modules, including manual addition to sys.path and changing environment variables on mac and windows.", 'chapters': [{'end': 510.438, 'start': 471.357, 'title': 'Importing modules from different directories', 'summary': "Illustrates the process of importing a module from a different directory, resulting in a 'module not found' error, when attempting to run the script.", 'duration': 39.081, 'highlights': ['The module being imported is moved from the current directory to a different directory on the desktop.', "An attempt to run the script after moving the module results in a 'module not found' error."]}, {'end': 669.832, 'start': 510.778, 'title': 'Setting python path and importing modules', 'summary': 'Discusses adding a directory to sys.path to import a module, demonstrating how to manually add the directory to sys.path and how to change the environment variables on mac and windows for the python path.', 'duration': 159.054, 'highlights': ['Demonstrating how to manually add the directory to sys.path The speaker explains the process of manually adding a directory to sys.path to import a module, and the significance of this approach in running the code successfully.', 'Explaining the process of changing the environment variables on Mac and Windows for the Python path The speaker provides a detailed walkthrough of setting environment variables by adding them to the dot bash underscore profile file in the home directory, and setting the Python path on Mac using the terminal.']}], 'duration': 198.475, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CqvZ3vGoGs0/pics/CqvZ3vGoGs0471357.jpg', 'highlights': ["An attempt to run the script after moving the module results in a 'module not found' error.", 'Demonstrating how to manually add the directory to sys.path.', 'Explaining the process of changing the environment variables on Mac and Windows for the Python path.']}, {'end': 833.131, 'segs': [{'end': 733.607, 'src': 'heatmap', 'start': 694.031, 'weight': 0, 'content': [{'end': 698.435, 'text': "And the reason that it's added is because we added it to our Python path environment variable.", 'start': 694.031, 'duration': 4.404}, {'end': 702.118, 'text': "So now let's take a look at how to set this environment variable on Windows.", 'start': 698.815, 'duration': 3.303}, {'end': 710.815, 'text': 'Now to set this environment variable on Windows, we can click on our Start button here, and then right-click on Computer and go to Properties.', 'start': 703.51, 'duration': 7.305}, {'end': 714.698, 'text': 'And from Properties, we want to go to Advanced System Settings.', 'start': 711.316, 'duration': 3.382}, {'end': 718.681, 'text': 'And from here, at the very bottom, we can click on Environment Variables.', 'start': 715.278, 'duration': 3.403}, {'end': 721.822, 'text': 'And now we can create a new environment variable.', 'start': 719.201, 'duration': 2.621}, {'end': 727.505, 'text': "So we'll click New, and we'll name this PythonPath, all uppercase there.", 'start': 722.162, 'duration': 5.343}, {'end': 733.607, 'text': "And then for the location, that's going to be C, we're going to go to the desktop again.", 'start': 728.105, 'duration': 5.502}], 'summary': 'Added python path to environment variable on windows.', 'duration': 39.576, 'max_score': 694.031, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CqvZ3vGoGs0/pics/CqvZ3vGoGs0694031.jpg'}, {'end': 813.376, 'src': 'embed', 'start': 767.847, 'weight': 1, 'content': [{'end': 771.469, 'text': 'And if we run that, and we can see that it imported that module successfully.', 'start': 767.847, 'duration': 3.622}, {'end': 780.278, 'text': 'Now, the reason that worked is because if we import sys and look at our sys And after our current directory,', 'start': 771.85, 'duration': 8.428}, {'end': 786.027, 'text': 'you can see that our directory that we added to our Python path is the second one that it looks at here.', 'start': 780.278, 'duration': 5.749}, {'end': 789.552, 'text': 'So that is how we add that environment variable on Windows.', 'start': 786.387, 'duration': 3.165}, {'end': 791.795, 'text': "So now I'll switch back to my native OS.", 'start': 789.692, 'duration': 2.103}, {'end': 798.683, 'text': "Now, I do wanna point out that if you're using an editor like Sublime Text or Eclipse or PyCharm,", 'start': 792.998, 'duration': 5.685}, {'end': 802.586, 'text': 'then these may need to have their environment variables set in a different way.', 'start': 798.683, 'duration': 3.903}, {'end': 804.508, 'text': "And that's different for every program.", 'start': 802.927, 'duration': 1.581}, {'end': 808.311, 'text': 'So, instead of going through each individual one and showing how,', 'start': 804.648, 'duration': 3.663}, {'end': 813.376, 'text': 'you can likely find out how to do that just by searching for your editor plus Python path.', 'start': 808.311, 'duration': 5.065}], 'summary': 'Demonstrated how to add environment variable on windows and mentioned different ways for different editors.', 'duration': 45.529, 'max_score': 767.847, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CqvZ3vGoGs0/pics/CqvZ3vGoGs0767847.jpg'}], 'start': 669.832, 'title': 'Setting python path on windows', 'summary': 'Explains how to set the python path environment variable on windows, including creating a new environment variable named pythonpath and setting its location to a specific directory, enabling the successful import of a custom module.', 'chapters': [{'end': 833.131, 'start': 669.832, 'title': 'Setting python path on windows', 'summary': 'Explains how to set the python path environment variable on windows, including creating a new environment variable named pythonpath and setting its location to a specific directory, enabling the successful import of a custom module.', 'duration': 163.299, 'highlights': ['The chapter explains how to set the Python path environment variable on Windows, including creating a new environment variable named PythonPath and setting its location to a specific directory, enabling the successful import of a custom module.', 'After adding the directory to the Python path environment variable, the chapter demonstrates the successful import of a custom module using the command prompt, illustrating the impact of the environment variable setting.', 'The chapter also mentions the need for different environment variable settings in editors like Sublime Text, Eclipse, or PyCharm, and suggests searching for specific instructions, providing guidance for users of various editors.']}], 'duration': 163.299, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CqvZ3vGoGs0/pics/CqvZ3vGoGs0669832.jpg', 'highlights': ['The chapter explains how to set the Python path environment variable on Windows, including creating a new environment variable named PythonPath and setting its location to a specific directory, enabling the successful import of a custom module.', 'After adding the directory to the Python path environment variable, the chapter demonstrates the successful import of a custom module using the command prompt, illustrating the impact of the environment variable setting.', 'The chapter also mentions the need for different environment variable settings in editors like Sublime Text, Eclipse, or PyCharm, and suggests searching for specific instructions, providing guidance for users of various editors.']}, {'end': 1304.237, 'segs': [{'end': 895.82, 'src': 'embed', 'start': 869.158, 'weight': 1, 'content': [{'end': 874.542, 'text': "So for example, let's say that we wanted to grab a random value from a list of values.", 'start': 869.158, 'duration': 5.384}, {'end': 877.745, 'text': 'So you could probably write something to do this on your own,', 'start': 874.843, 'duration': 2.902}, {'end': 883.13, 'text': 'but that functionality is already available to us when we use the random module from the standard library.', 'start': 877.745, 'duration': 5.385}, {'end': 885.192, 'text': "So let's go ahead and take a look at this.", 'start': 883.45, 'duration': 1.742}, {'end': 887.874, 'text': "So I'll get rid of everything here just to clean up.", 'start': 885.232, 'duration': 2.642}, {'end': 890.196, 'text': 'except for our courses list.', 'start': 888.254, 'duration': 1.942}, {'end': 895.82, 'text': 'now this random module is just part of the standard library and we can just say import random,', 'start': 890.196, 'duration': 5.624}], 'summary': 'The random module from the standard library provides functionality to grab a random value from a list of values.', 'duration': 26.662, 'max_score': 869.158, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CqvZ3vGoGs0/pics/CqvZ3vGoGs0869158.jpg'}, {'end': 1148.961, 'src': 'heatmap', 'start': 1060.046, 'weight': 0, 'content': [{'end': 1065.212, 'text': 'It gives us the ability to scan the file system and create files, delete files, and all of that.', 'start': 1060.046, 'duration': 5.166}, {'end': 1072.878, 'text': 'So you can see how these standard library modules provide a ton of functionality that might be tricky or take forever for us to write ourselves.', 'start': 1065.592, 'duration': 7.286}, {'end': 1079.282, 'text': 'So Python comes with a ton of stuff available to us and makes it super easy to get them imported and running.', 'start': 1073.258, 'duration': 6.024}, {'end': 1085.205, 'text': 'So another great thing about Python is that these modules are just Python files themselves,', 'start': 1079.662, 'duration': 5.543}, {'end': 1092.289, 'text': 'and we can view the location of a module just by printing out its dunder file method or its dunder file attribute.', 'start': 1085.205, 'duration': 7.084}, {'end': 1092.669, 'text': "I'm sorry.", 'start': 1092.289, 'duration': 0.38}, {'end': 1098.872, 'text': 'So if we print out os.py, dunder file, and dunder just means two underscores.', 'start': 1092.989, 'duration': 5.883}, {'end': 1103.274, 'text': "And don't worry why those are double underscores, that'll be a topic for a future video.", 'start': 1099.252, 'duration': 4.022}, {'end': 1109.277, 'text': 'So if we run this, then we can see that it prints out the location of this file on our file system.', 'start': 1103.614, 'duration': 5.663}, {'end': 1116.5, 'text': 'And if we open up that Python directory where that file lives, then we could see the entire standard library.', 'start': 1109.737, 'duration': 6.763}, {'end': 1121.122, 'text': 'So I actually have this open right here, so let me open this up real quick.', 'start': 1116.86, 'duration': 4.262}, {'end': 1126.505, 'text': 'So I actually have opened that Python 3.6 directory where the entire standard library lives.', 'start': 1121.502, 'duration': 5.003}, {'end': 1134.731, 'text': "Now, I know that this may be a little small over here for you to see on my screen, but let's go ahead and look through a couple of these files.", 'start': 1126.826, 'duration': 7.905}, {'end': 1136.632, 'text': 'So these are all in alphabetical order.', 'start': 1135.091, 'duration': 1.541}, {'end': 1141.636, 'text': 'So one of the first files in the standard library is actually this anti-gravity module.', 'start': 1136.672, 'duration': 4.964}, {'end': 1144.818, 'text': 'Now, this is kind of a joke in the Python community.', 'start': 1141.976, 'duration': 2.842}, {'end': 1148.961, 'text': 'So this is a module that you can import called anti-gravity.', 'start': 1145.138, 'duration': 3.823}], 'summary': 'Python standard library provides extensive functionality and easy module access.', 'duration': 43.228, 'max_score': 1060.046, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CqvZ3vGoGs0/pics/CqvZ3vGoGs01060046.jpg'}, {'end': 1195.539, 'src': 'heatmap', 'start': 1172.067, 'weight': 0.943, 'content': [{'end': 1179.069, 'text': "So back in intro.py, I'll just delete everything and do import anti-gravity and run this file.", 'start': 1172.067, 'duration': 7.002}, {'end': 1186.855, 'text': "Then we can see it just opens up our web browser to this comic, and I'll leave this open while we close out here.", 'start': 1180.933, 'duration': 5.922}, {'end': 1193.358, 'text': "So if you get a chance, then don't be afraid to go into the standard library and look around at how different things are done.", 'start': 1187.316, 'duration': 6.042}, {'end': 1195.539, 'text': "It's a great way to learn.", 'start': 1193.958, 'duration': 1.581}], 'summary': 'Running intro.py with import anti-gravity opens a web comic, encouraging exploration of the standard library for learning.', 'duration': 23.472, 'max_score': 1172.067, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CqvZ3vGoGs0/pics/CqvZ3vGoGs01172067.jpg'}, {'end': 1234.956, 'src': 'embed', 'start': 1211.505, 'weight': 4, 'content': [{'end': 1218.628, 'text': "So we've learned about different data types, conditionals, loops, functions, and importing modules, and a bit of the standard library.", 'start': 1211.505, 'duration': 7.123}, {'end': 1225.951, 'text': "Now, I think that just about anyone would agree that, no matter what specialty you plan on going into for Python whether it's backend,", 'start': 1219.028, 'duration': 6.923}, {'end': 1227.972, 'text': 'web development, data science,', 'start': 1225.951, 'duration': 2.021}, {'end': 1234.956, 'text': "building desktop applications no matter what route you decide to take you're going to need the fundamentals that we've covered up until this point.", 'start': 1227.972, 'duration': 6.984}], 'summary': 'Covered various python fundamentals, essential for any specialty or route in python development.', 'duration': 23.451, 'max_score': 1211.505, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CqvZ3vGoGs0/pics/CqvZ3vGoGs01211505.jpg'}], 'start': 833.472, 'title': 'Python standard library', 'summary': "Covers the benefits and overview of using the python standard library, emphasizing extensive functionality, optimization by skilled programmers, and specific modules such as math, datetime, calendar, and os. it provides examples of module usage, such as selecting random values and converting degrees into radians and encourages exploration of the library's modules.", 'chapters': [{'end': 935.941, 'start': 833.472, 'title': 'Benefits of using python standard library', 'summary': 'Highlights the benefits of using the python standard library, emphasizing its extensive functionality and optimization by skilled programmers, and provides an example of utilizing the random module to select random values from a list.', 'duration': 102.469, 'highlights': ['The standard library in Python eliminates the need for separate installations and offers optimized functionality written by experienced programmers.', 'Using the random module from the standard library allows for easy selection of random values from a list, enhancing efficiency and productivity.', 'Exploring the extensive functionality of the standard library modules will be covered in a future video, showcasing the diverse capabilities available for use.']}, {'end': 1304.237, 'start': 936.221, 'title': 'Python standard library overview', 'summary': 'Covers the use of math, datetime, calendar, and os modules in python, including examples of converting degrees into radians, checking leap year, and accessing the operating system functionality. it also emphasizes the significance of the standard library and encourages exploration of its modules.', 'duration': 368.016, 'highlights': ['The standard library provides a ton of functionality, making it super easy to get them imported and running. It includes modules for mathematical operations, working with dates and times, and accessing the operating system, simplifying complex tasks. For instance, converting 90 degrees into radians using math.radians and checking if 2017 is a leap year using calendar.isleap are demonstrated.', "The location of a module can be viewed by printing out its dunder file attribute, allowing easy exploration of the entire standard library and understanding how different things are done. This encourages learning and provides insights into the Python modules' implementation.", "The anti-gravity module, although a joke in the Python community, showcases the fun and quirky side of the standard library, with the ability to open a web comic on the machine. Exploring such modules serves as a great way to learn and understand Python's capabilities.", "The video emphasizes the importance of mastering the fundamental concepts in Python, such as different data types, conditionals, loops, functions, and importing modules, as they are essential regardless of the specialty one plans to pursue, whether it's backend development, data science, or building applications."]}], 'duration': 470.765, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CqvZ3vGoGs0/pics/CqvZ3vGoGs0833472.jpg', 'highlights': ['The standard library in Python eliminates the need for separate installations and offers optimized functionality written by experienced programmers.', 'Using the random module from the standard library allows for easy selection of random values from a list, enhancing efficiency and productivity.', 'The standard library provides a ton of functionality, making it super easy to get them imported and running. It includes modules for mathematical operations, working with dates and times, and accessing the operating system, simplifying complex tasks.', "The location of a module can be viewed by printing out its dunder file attribute, allowing easy exploration of the entire standard library and understanding how different things are done. This encourages learning and provides insights into the Python modules' implementation.", "The video emphasizes the importance of mastering the fundamental concepts in Python, such as different data types, conditionals, loops, functions, and importing modules, as they are essential regardless of the specialty one plans to pursue, whether it's backend development, data science, or building applications."]}], 'highlights': ['The standard library in Python eliminates the need for separate installations and offers optimized functionality written by experienced programmers.', 'Using the random module from the standard library allows for easy selection of random values from a list, enhancing efficiency and productivity.', 'The standard library provides a ton of functionality, making it super easy to get them imported and running. It includes modules for mathematical operations, working with dates and times, and accessing the operating system, simplifying complex tasks.', "The location of a module can be viewed by printing out its dunder file attribute, allowing easy exploration of the entire standard library and understanding how different things are done. This encourages learning and provides insights into the Python modules' implementation.", 'The chapter covers the process of importing modules in Python, including how to import modules, use functions from imported modules, and specify aliases for imported modules. It provides an overview of the main focus of the chapter, highlighting the key topics covered.', "The find index function in the module mymodule.py returns the index of a value in a sequence, and if it doesn't find the value, it returns -1. Describes the functionality of the find index function and its return values, providing a clear understanding of its purpose.", 'Importing modules involves running all the code from the module being imported, including functions, variables, and print statements. Explains the process of importing modules and the consequent execution of all code within the module, including functions, variables, and print statements.', 'The chapter explains how to set the Python path environment variable on Windows, including creating a new environment variable named PythonPath and setting its location to a specific directory, enabling the successful import of a custom module.', 'After adding the directory to the Python path environment variable, the chapter demonstrates the successful import of a custom module using the command prompt, illustrating the impact of the environment variable setting.', 'The chapter also mentions the need for different environment variable settings in editors like Sublime Text, Eclipse, or PyCharm, and suggests searching for specific instructions, providing guidance for users of various editors.', 'Python locates modules through sys.path list, Python path environment variable, standard library directories, and site packages directory.', 'The directory containing the script being run is the first value in sys.path list.', "Risks and best practices of using 'import star' are discussed.", "An attempt to run the script after moving the module results in a 'module not found' error.", 'Demonstrating how to manually add the directory to sys.path.', 'Explaining the process of changing the environment variables on Mac and Windows for the Python path.', "The video emphasizes the importance of mastering the fundamental concepts in Python, such as different data types, conditionals, loops, functions, and importing modules, as they are essential regardless of the specialty one plans to pursue, whether it's backend development, data science, or building applications."]}