It pains me to see that this seems to be so difficult and so much underdocumented that a longterm forum participant like you seems to get frustrated to the point that you ask if this is even possible.
Why wouldn’t it?
I just tried the search on this forum with “attach file python” and found this which, depending on the precise situation of where your code-to-be needs to be located, might help you or not:
Best!