Sorry for the tremendous delay in reply. So, just to be clear, you're wanting to be able to call generate_data.py and send_data.pydirectly, and those are supposed to be able to import a module from elsewhere in the project?
If so, I would actually consider why you want to execute those modules directly. If you're simply wanting to be able to execute the two separately from the command-line, it may be worth fleshing out __main__.py to accept a command-line argument, so python3 -m generateandsend send or python3 -m generateandsend generate will execute what you want. That'll also be the easiest solution. That way, you're always executing the top-level package (generateandsend)
In fact, I'm not entirely sure off the top of my head how to get multiple projects to talk to one another within a shared directory! I know it has to do with PYTHONPATH, but I think that will necessitate more research on my part. ;)
Thanks for replying (& no problem on the delay - we all have a life to live!).
I have thought about this more and agree - Why is it that I want to call them separately, where a parameter will suffice. So, I have abandoned the idea and gone with the python3 -m generateandsend generate approach
Cheers for the reply though. Appreciated.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi Ashley,
Sorry for the tremendous delay in reply. So, just to be clear, you're wanting to be able to call
generate_data.py
andsend_data.py
directly, and those are supposed to be able to import a module from elsewhere in the project?If so, I would actually consider why you want to execute those modules directly. If you're simply wanting to be able to execute the two separately from the command-line, it may be worth fleshing out
__main__.py
to accept a command-line argument, sopython3 -m generateandsend send
orpython3 -m generateandsend generate
will execute what you want. That'll also be the easiest solution. That way, you're always executing the top-level package (generateandsend
)In fact, I'm not entirely sure off the top of my head how to get multiple projects to talk to one another within a shared directory! I know it has to do with
PYTHONPATH
, but I think that will necessitate more research on my part. ;)Thanks for replying (& no problem on the delay - we all have a life to live!).
I have thought about this more and agree - Why is it that I want to call them separately, where a parameter will suffice. So, I have abandoned the idea and gone with the
python3 -m generateandsend generate
approachCheers for the reply though. Appreciated.