Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import functions from one python file to another

Say i have a python file called a.py with the functions x,y,z.

I want to import them to a new file called b.py

I tried: from a import * AND from a import all with no luck.

I can just do it separately: from a import x , from a import y ....

How can i import them ALL at once?

like image 979
shayms8 Avatar asked Dec 11 '22 09:12

shayms8


1 Answers

You can import a file and then use the functions on that file using the import name before the function name.

import example #this import the entire file named example.py

example.myfunction() #this call a function from example file
like image 152
Saelyth Avatar answered Dec 25 '22 12:12

Saelyth