Yes, the god of Suffering has many faces. The last one is my favorite.

Let me explain the issue.

Your colleague has given you these wonderful, brand-new Python scripts to end all the injustices in the world. You are ready to go, eager to run them, but you can’t import any of their functions and classes.

Not only you can’t import them from one script to another, but you can’t import them from your running Python interpreter as well.

Or maybe you can, but only if _Jupyter _and Saturn are aligned. In that same folder. Or like a PyCharmAnd nobody else can do the same.

So you (or your kind colleague for you) have chosen the patchy way.

The Way of Suffering.

You have modified your PYTHONPATH . Or similar. You were forced to do so. And it’s a mess.

The import chaos for your code

As you might have noticed, I’m talking about the chaos that Python imports can generate. Or, better, the chaos that messy configuration can generate.

Because imports have no faults on their own, poor little creatures (that’s not true, I do have some things to say on that… but not now).

The real issue is the way they are used or supposed to be used.

From Tricks to Ghosts

I’ve seen several hacks to avoid this import issue.

Just some special mentions here, to underline why they are bad in general and what risks they pose.

If you just want to know the final working solution, without knowing why it is better than these tricks, skip this part!

#technology #programming #python

Import Your Own Python Code Without Pythonpath Tricks
13.40 GEEK