Package directory question
Robert Latest
boblatest at yahoo.com
Mon Jun 25 14:49:19 EDT 2018
Ben Finney wrote:
> Robert Latest via Python-list <python-list at python.org> writes:
>
>> Because the main.py script needs to import the tables.py module from
>> backend, I put this at the top if main.py:
>>
>> sys.path.append('../..')
>> import jobwatch.backend.tables as tables
>>
>> My question is: Is this the way it should be done? It looks fishy. The
>> only alternative I could come up with is to put a symlink to tables.py
>> into the frontend directory, which also seems fishy.
>
> Your fish-sense is working correctly. Both of those are hard-coding the
> path, when the Python import mechanism is designed so you don't do that.
[...]
> * To install for use while also developing, add the ‘--editable’ option.
Ah, that's what I needed. Of course the problem I had was only present
during development. I haven't really looked into pip yet, so far I've
been using only "python setup.py install".
Thanks,
robert
More information about the Python-list
mailing list