Skip to content Skip to sidebar Skip to footer

How To Import My Own Modules In Python 3.6?

Let's say I have a file like: Project0\pizza.py Project0\make_pizza.py and pizza: def make_pizza(size,*toppings): print('\nMaking a ' + str(size) + '-inch pizza with the fo

Solution 1:

You're importing it correctly, but you're calling it incorrectly.

The correct way to call it is:

make_pizza(16, 'pepperoni')

Solution 2:

You imported only the function make_pizza in your make_pizza.py so you can just use make_pizza without redefining pizza (since Python has already loaded this):

from pizza import make_pizza 
make_pizza(16, 'pepperoni')

As mentioned in the comments below you could use this function, but then you would need to import pizza and not just part of it.

Solution 3:

because the module directory is not available in the PATH environment variable.

Post a Comment for "How To Import My Own Modules In Python 3.6?"