Search
- Filter Results
- Location
- Classification
- Include attachments
- https://eng.libretexts.org/Bookshelves/Computer_Science/Programming_Languages/Python_Programming_(OpenStax)/07%3A_Modules/7.03%3A_Top-level_CodeThis page discusses Python module behavior, highlighting potential side effects from importing modules and the significance of the `if __name__ == "__main__"` statement. It explains that top-level cod...This page discusses Python module behavior, highlighting potential side effects from importing modules and the significance of the `if __name__ == "__main__"` statement. It explains that top-level code runs upon import, which can lead to unintended consequences, and provides examples to illustrate this. The text emphasizes the importance of using the conditional statement to control execution and prevent code from running prematurely. Exercises are included to reinforce the concepts presented.
- https://eng.libretexts.org/Bookshelves/Computer_Science/Programming_Languages/Python_Programming_(OpenStax)/07%3A_Modules/7.02%3A_Importing_NamesThis page discusses learning objectives for importing functions in Python using the "from" keyword, emphasizing direct imports and name collision risks. It provides checkpoints and practice questions ...This page discusses learning objectives for importing functions in Python using the "from" keyword, emphasizing direct imports and name collision risks. It provides checkpoints and practice questions to strengthen understanding. The importance of careful naming to avoid unexpected behavior due to name conflicts, which do not generate errors in Python, is also highlighted.
- https://eng.libretexts.org/Bookshelves/Computer_Science/Programming_Languages/Python_Programming_(OpenStax)/11%3A_Classes/11.05%3A_Using_Modules_with_ClassesThis page covers selective class imports from modules, creating aliases, and emphasizes module organization for reusability. Key concepts include using import statements, the advantages of aliasing to...This page covers selective class imports from modules, creating aliases, and emphasizes module organization for reusability. Key concepts include using import statements, the advantages of aliasing to avoid naming collisions, and practical exercises that reinforce these ideas through questions on module class counts, correct imports, and fixing missing statements.
- https://eng.libretexts.org/Bookshelves/Computer_Science/Programming_Languages/Python_Programming_(OpenStax)/16%3A_Answer_Key/16.06%3A_Chapter_7This page offers an overview of Python modules, covering fundamentals like importing, top-level code, and the use of the help function. It discusses defining functions within modules, the importance o...This page offers an overview of Python modules, covering fundamentals like importing, top-level code, and the use of the help function. It discusses defining functions within modules, the importance of the __name__ variable, and handling imports and name errors. Documentation organization, including docstrings, standard libraries such as tkinter and MoviePy, and hexadecimal color representation are also addressed.
- https://eng.libretexts.org/Bookshelves/Computer_Science/Programming_Languages/Python_Programming_(OpenStax)/07%3A_Modules/7.00%3A_IntroductionThis page emphasizes the importance of organizing code into modules for larger, complex programs. It covers how to define, import, and locate modules, and highlights Python's extensive standard librar...This page emphasizes the importance of organizing code into modules for larger, complex programs. It covers how to define, import, and locate modules, and highlights Python's extensive standard library with over 200 built-in modules. A module is identified as a .py file containing function definitions, with its name matching the file name. While all programs can function as modules, not all are intended for direct execution, exemplified by the greetings.
- https://eng.libretexts.org/Bookshelves/Computer_Science/Programming_Languages/Python_Programming_(OpenStax)/07%3A_Modules/7.06%3A_Chapter_SummaryThis page covers organizing Python programs through the use of multiple .py files (modules) and the import system. It emphasizes the significance of the if __name__ == "__main__" statement for executi...This page covers organizing Python programs through the use of multiple .py files (modules) and the import system. It emphasizes the significance of the if __name__ == "__main__" statement for execution control. The help() function is introduced for accessing module documentation, and there are over 200 built-in modules available, along with many third-party options. The chapter includes examples of importing modules and accessing their documentation.