In the __init__.py
:
def tp(msg,o=None):
import datetime
omsg = ": %s" %repr(o) if o is not None else ""
dtf = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
print(f"[{dtf}] {msg}{omsg}")
In a .py
file in the same directory (/package ?) :
Traceback (most recent call last):
File "/git/bluej/python/pointr/bluej/fusion/json_generators.py", line 243, in <module>
tp('Running human-in-loop tests ..')
NameError: name 'tp' is not defined
What is the point of having __init__.py
if the contents are not even visible to the files in the same package?
RE: the linked question and answers. It/they do not actually address my question here.
Update I learnt how to run the script as a module
within pycharm
and that mostly took care of the issue. The tp()
runs now: but it is still required to do
from . import tp