Dumb questions about import user-written functions

Hi, there:

I have a very dumb question about importing self defined functions. I copy the file “solow.py” in my working directory and import it as typing “import solow”. However, when I try to used the class “Solow” defined in the code, Python shows the error that “Solow” is not defined? What is supposed to be the way to write a function and let the system to be aware so I can use it?


Hi. What you are looking for is

from solow import Solow

This will find the file solow.py (assuming it is in the current directory) and import the class (also works for constants or functions) Solow.

1 Like

cc7768: thank you very much.

That’s okay, i actually have had the same question some time ago, and i was so stupid because i didn’t wanted to ask, thinking that I’m going to look really stupid! Anyway is good to ask :slight_smile: hope that you found a good answer! I’m really thankful for your forum, i find a lot of answers to questions i needed, i love to spend time here, as i forget about my health problems, and i don’t have to spend so many time searching for drug reviews