Forum Archive

Import Command

Python567

I want to be able to import another file and then run it in. For example:
I have a file with a print command in it. In my other file I want to import and execute it. How do I do that?

ccc

% cat a.py
import b
% cat b.py
print("Hello")
% python3 a.py
Hello

Python567

@ccc Sorry, I don‘t understand that.

ccc
  1. Put into a.py the text import b
  2. Put into b.py the text print("Hello")
  3. Run a.py and it should output Hello