Call a function from another file?

user2977230

Set_up: I have a .py file for each function I need to use in a program.

In this program, I need to call the function from the external files.

I've tried:

from file.py import function(a,b)

But I get the error:

ImportError: No module named 'file.py'; file is not a package

How do I fix this problem?

Games Brainiac

There isn't any need to add file.py while importing. Just write from file import function, and then call the function using function(a, b). The reason why this may not work, is because file is one of Python's core modules, so I suggest you change the name of your file.

Note that if you're trying to import functions from a.py to a file called b.py, you will need to make sure that a.py and b.py are in the same directory.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

AngularJS Call function from another file

From Dev

Call function from another file in BrightScript

From Dev

Mediawiki Call hook function from another file

From Dev

Call function from another file in BrightScript

From Dev

Mediawiki Call hook function from another file

From Dev

PHP How to call a function from another class and another file?

From Dev

create java function in a jsp file and call it from another jsp file

From Dev

create java function in a jsp file and call it from another jsp file

From Dev

How to call the static function from another c file?

From Dev

Call another function from within same script file

From Dev

C++ call inline function from another cpp file

From Dev

LLVM Insert function call defined from another file

From Dev

maya python call function from another py file

From Dev

Call channel connect function from another js file

From Dev

How can i call a assembly function from another assembly file?

From Dev

Call function from another file without import clause?

From Dev

How to call a php function from another php file

From Dev

C++ call inline function from another cpp file

From Dev

Aframe - call aframe function from another javascript file

From Dev

Function call by address from map file of another project

From Dev

Js how call function and pass params from another file

From Dev

C++ How to call a function from another file with the same name as a function in another file when both are included?

From Dev

Call function in another lisp file

From Dev

Call function from another script

From Dev

Call a function from another thread

From Dev

Call a function from an another class

From Dev

Call an anonymous function from another

From Dev

How can I call a function in another CFC file from within a query of a function in one cfc file?

From Dev

Call function from another function Mysql

Related Related

  1. 1

    AngularJS Call function from another file

  2. 2

    Call function from another file in BrightScript

  3. 3

    Mediawiki Call hook function from another file

  4. 4

    Call function from another file in BrightScript

  5. 5

    Mediawiki Call hook function from another file

  6. 6

    PHP How to call a function from another class and another file?

  7. 7

    create java function in a jsp file and call it from another jsp file

  8. 8

    create java function in a jsp file and call it from another jsp file

  9. 9

    How to call the static function from another c file?

  10. 10

    Call another function from within same script file

  11. 11

    C++ call inline function from another cpp file

  12. 12

    LLVM Insert function call defined from another file

  13. 13

    maya python call function from another py file

  14. 14

    Call channel connect function from another js file

  15. 15

    How can i call a assembly function from another assembly file?

  16. 16

    Call function from another file without import clause?

  17. 17

    How to call a php function from another php file

  18. 18

    C++ call inline function from another cpp file

  19. 19

    Aframe - call aframe function from another javascript file

  20. 20

    Function call by address from map file of another project

  21. 21

    Js how call function and pass params from another file

  22. 22

    C++ How to call a function from another file with the same name as a function in another file when both are included?

  23. 23

    Call function in another lisp file

  24. 24

    Call function from another script

  25. 25

    Call a function from another thread

  26. 26

    Call a function from an another class

  27. 27

    Call an anonymous function from another

  28. 28

    How can I call a function in another CFC file from within a query of a function in one cfc file?

  29. 29

    Call function from another function Mysql

HotTag

Archive