import pizza_module as pizza

pizza.make_pizza(16, 'pepperoni')
pizza.make_pizza(12, 'mushrooms', 'green peppers', 'extra cheese')
Ejemplo n.º 2
0
# Here we give the function make_pizza() an alias, mp(), by importing make_pizza as mp.

from pizza_module import make_pizza as mp

mp(16, 'pepperoni')
mp(12, 'mushrooms', 'green peppers', 'extra cheese')

########################################################################################################################
#                                       Using as to Give a Module an Alias                                             #
########################################################################################################################

# You can also provide an alias for a module name
# General syntax for this approach is:
# import module_name as mn

import pizza_module as p

p.make_pizza(15, 'pepperoni')
p.make_pizza(10, 'mushrooms', 'green peppers')

########################################################################################################################
#                                      Importing All Functions in a Module                                             #
########################################################################################################################

# You can tell Python to import every function in a module by using the asterisk (*) operator:
# from module_name import *

from pizza_module import *

make_pizza(5, 'meatlovers')
make_pizza(4, 'vegetarian')
Ejemplo n.º 3
0
""" Importing modules: module alias """

import pizza_module as p

p.make_pizza(16, 'pepperoni')
p.make_pizza(12, 'mushrooms', 'green peppers', 'extra cheese')
Ejemplo n.º 4
0
from pizza_module import make_pizza, make_pizza_loop

make_pizza('pepperoni')
make_pizza('mushrooms', 'green peppers', 'extra cheese')

print('====================')

make_pizza_loop('pepperoni')
make_pizza_loop('mushrooms', 'green peppers', 'extra cheese')

Ejemplo n.º 5
0
import pizza_module

pizza_module.make_pizza('Large', 'Onion', 'Black Olive', "Cottage cheese")
Ejemplo n.º 6
0
#import an entire module
import pizza_module

#import specific functions
from pizza_module import make_pizza

#Using 'as' to give a function an alias
from pizza_module import make_pizza as mp

#Using 'as' to give a module an alias
import pizza_module as p

#Import all functions from a module
from pizza_module import *

pizza_module.make_pizza(16, 'pepperoni')
print("\n")

make_pizza(12, 'ham')
print("\n")

mp(8, 'mushrooms', 'green peppers')
print("\n")

p.make_pizza(16, 'chicken')
print("\n")
Ejemplo n.º 7
0
#Method 1: import whole module
import pizza_module

pizza_module.make_pizza(16, 'pepperoni')
pizza_module.make_pizza(16, 'pepperoni', 'pete hair')

#Method 2: import specifc fxn from module
from pizza_module import make_pizza

make_pizza(16, 'cheese', 'salami')

#Method 3: fxn alias

from pizza_module import make_pizza as mp
mp(14, 'no sauce', 'extra cheese')

#Method 4: module alias

import pizza_module as p

p.make_pizza(11, 'cheese', 'more cheese')

#Method 5: Import all functions in module

from pizza_module import *

make_pizza(10, 'cheese', 'zebras')
Ejemplo n.º 8
0
# CH8 Example
#
# making_pizzas.py
#
# Importing a module

# this module comes from pizza_module.py and only includes the function we want:
# make_pizza()
# Can also import specific functions: "from pizza_module import make_pizza"
import pizza_module

# Output is the exact same as in pizza-2.py
# dot notation is not required if importing specific functions from a module
pizza_module.make_pizza(16, 'pepperoni')
pizza_module.make_pizza(12, 'pineapple', 'sausage', 'anchovies')
Ejemplo n.º 9
0
import pizza_module

pizza_module.make_pizza('pepperoni')
pizza_module.make_pizza('mushrooms', 'green peppers', 'extra cheese')

print('====================')

pizza_module.make_pizza_loop('pepperoni')
pizza_module.make_pizza_loop('mushrooms', 'green peppers', 'extra cheese')

print('====================')

pizza_module.make_pizza_with_size(16, 'pepperoni')
pizza_module.make_pizza_with_size(12, 'mushrooms', 'green peppers',
                                  'extra cheese')
Ejemplo n.º 10
0
import pizza_module as pizza
pizza.make_pizza(16, 'pepperoni')
pizza.make_pizza(12, 'mushrooms', 'green peppers', 'extra cheese')

from pizza_module import make_pizza
make_pizza(20, 'pepperoni')
make_pizza(30, 'mushrooms', 'green peppers', 'extra cheese')

from pizza_module import make_pizza as make
make(25, 'pepperoni')
make(35, 'mushrooms', 'green peppers', 'extra cheese')

from pizza_module import *
make_pizza(25, 'pepperoni')
make_pizza(35, 'mushrooms', 'green peppers', 'extra cheese')
Ejemplo n.º 11
0
from pizza_module import make_pizza

# do not need to specify module to call function
make_pizza(16, 'pepperoni')
make_pizza(12, 'mushrooms', 'green peppers', 'glitter')