Menu

Call a function from other .py file.

2009-08-11
2013-03-15
  • Python lover

    Python lover - 2009-08-11

    I am a newbie to Python.
    I have two .py files: main.py and func.py. func.py has a function and main.py has a code calling the function. When I run it I got error message - "NameError: name 'print_ln' is not defined".
    Anyone knows how to call a function which is not defined in the same .py file?

     
    • Fabio Zadrozny

      Fabio Zadrozny - 2009-08-13

      You have to import it.

      Note that this forum is not appropriate for questions related to how to program in python... Usually the python list is a better place (python-list@python.org) and they can point you to tutorials, etc.

      Cheers,

      Fabio

       
MongoDB Logo MongoDB