Python Forum
A bash script that is a hack to enable very easy Python Imports
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A bash script that is a hack to enable very easy Python Imports
#1
Python projects that have complex codebase directory structures introduce a fairly common problem with imports within the project. While providing absolute paths is recommended, it is cumbersome, repetitive, and rather boilerplate. Absolute imports may also decrease application portability. pyosphere.sh mitigates these issues by simply providing a flattened execution environment, allowing all files to relatively import each other trivially, while allowing developers to maintain their choice of directory structure.

Note: This is just a hack to make things easy while importing. Use at own will.

I do hope people will like this since it does make importing files easy as well as running files from other directories as well.

It is completely open source and can be found at: https://github.com/vedantpuri/pyosphere

Feel free to check it out and leave behind a star if you like it !
Reply
#2
Could you give some examples of the code you think is bad and the code you can write instead?
Reply
#3
You don't need bash for that.

If you want to import foo you can scan for foo.py and add its full path to the PYTHONPATH.
All this can be done in try/except block.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  SeePy and Loge - easy and fast dynamic report generation with Python lucke 1 3,869 Dec-10-2020, 07:58 PM
Last Post: lucke
  script to check bash scripts Skaperen 3 2,691 Sep-19-2019, 10:26 PM
Last Post: Skaperen
Lightbulb Script broke with Python 3 / improve script for printing aspecteleven 4 4,527 Feb-22-2019, 12:23 PM
Last Post: buran
  bash to python: keep.py Skaperen 0 2,772 Apr-08-2017, 07:27 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020