I would like to ask: Is there (in Python) any way, how to absolutelly stupidly include other file into source code? Without any dancings like modules etc, i.e. equivalent #include from C ? There were laid many questions about this, but all of them are turning on import modules. No, I want only insert some text lines from any file to my code without preprocess it.
For example:
Let's file mysum.py
c = a + b # there is just this one line
And I want to include to another source code: file experiment.py:
#!/usr/bin/python
# -*- coding: UTF8 -*-
import importlib
import sys
import math
a = 1
b = 2
import **mysum**
print c
Well, it does not work,
Traceback (most recent call last):
File "./experiment.py", line 12, in <module>
import mysum
File "/home/rna/unix/mypok/mysum.py", line 5, in <module>
c = a + b
NameError: name 'a' is not defined
I really need one short header file include to more different scripts, there would be definitions variables about MySQL connection and similar data, common for more scripts.