0

I have a subfile, for example ex1.h, which contains some of my code, for example print('Test something').

Now I want to include it to my main file, i.e. main.py, such that

#include 'ex1.h'

And when I run the python file main.py, I want it to print out the message: Test something. Is there any way to do that with python?

ForceBru
  • 43,482
  • 10
  • 63
  • 98
bin bin
  • 3
  • 1
  • Do you mean importing a C/C++ header from Python code? Or do you mean importing another python file. – zrfrank May 16 '20 at 07:08
  • Also see Python's tutorial on modules: https://docs.python.org/3/tutorial/modules.html – ForceBru May 16 '20 at 07:08
  • Hi zrfank, because my python code is long, so I want to slit it out, so that I can call it back. For example, I have a list of names, and I want to print them: print('abc'), print('ads'), print('fde'),...., and so forth. I want to slit all of print('...') in another file, so that I can easy to add new name without open my main python file. (But I do not want to make a file to read a list of name) – bin bin May 16 '20 at 08:06

0 Answers0