Maryam Saeedi wrote:
Yes, the separate file become a module.
Yes. either of
import somemod # and use somemod.func
from somemod import func # and use func
The function can access built-in objects and objects in the module it is
defined in. Otherwise, it has locals just as usual.
Yes.
Look at Python coded files in the the standard library. Look in
..../Pythonx.y/Lib to find them.
tjr
Hi all,
>
I have a very basic question. I was wondering if I can have a function
in a separate file
>
I have a very basic question. I was wondering if I can have a function
in a separate file
and in my main file sort of import that function and
import somemod # and use somemod.func
from somemod import func # and use func
if so are all the variables local
defined in. Otherwise, it has locals just as usual.
and if I need any variables in the function I should give it as an input?
I need to call a function in many different tasks and I am improving
that function so I prefer to make the changes only once. If you have any
example I really appreciate it.
that function so I prefer to make the changes only once. If you have any
example I really appreciate it.
..../Pythonx.y/Lib to find them.
tjr