its320 chapter 11 modules

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

import structure

Construct 11.3.1: Importing specific names from a module. from module_name import name1, name2, ...

built in module

a module that come pre-installed with python, some are sys, time, and math.

from keyword

a programmer can specify names to import from a module and use from

hashlib

a python standard library module that contains a number of algorithms for creating a secure hash

reload()

function can be used to reload and re-execute the changed module. This is used becuase when you import a module it only runs once and if it needs to be changed just use the reload() function

import

importing a module means to execute the code contained by the module and make the definitions within that module available for use by importing the program

packages

instead of only using import for a single module, packages gives access to all of the modules. used for large projects.

__name__

is a global string variable automatically added to every module that contains the name of the module example my_funcs__name__ would have the value "my_funcs" this is always set to __main__

module object

is if the module has not been loaded in the sys.module then a new module is create. It is a namespace that contains definitions from the module

sys.path

is the list of directories

__main__

is to differentiate the script from imported modules example if __name__ == "__main__": if this is true then the file is being executed as a script and the branch is taken.

script

is where a programmer writes python code and passes the code to the file into an input to the interpreter

environmental variable

like a variable in python except hat it is stored in the computer's operating system and be accessed by every program running on the computer

PYTHONPATH

place in the module this is the environmental variable

__file__

special name contains the path to a module in the computer file system

hash

text message. a secure hash correlates exactly to a single series of characters

__init__.py

the __init__.py is used to indicate that a directory is a package. the __init__.py is usually empty but may contain code to initialize the package when improted

access items in namespace

use the dot method ex: Complete the statement to call the draw_square function from the shapes module, passing an argument of 3. shapes.draw_square(3) shapes.draw_square(3) Dot notation is used to access items in the namespace of the imported module.

module

when a programmer writes the same function over and over it is easier to use a module, which is a file containing python doce that can be imported and used by scripts other modules or the interactive interpreter.


Ensembles d'études connexes

Unit 7 - Practice Exam 2 (Issuing Securities)

View Set

Central Venous Access Device (CVAD)

View Set

Chapter 9 Accounting for Current Liabilities

View Set

Dion: Comptia CySA - Practice Test 6

View Set

Syngas, Hydrogen and Liquid Fuels

View Set

Module 6 - Organizational Change

View Set

GENETICS- MUTATIONS-repair mechanisms

View Set

Georgia Studies Vocabulary - On Going List.

View Set

1.9 Agents Of Socialization: Family, Schools, Peers And Media

View Set

Chapter 5 Ethernet (802.3) Switched LANs

View Set