Skip to main content

Posts

Showing posts from October, 2019

Develop Python scripts cross platform

This post was an answer to my own question: https://twitter.com/changliao1025/status/1182847707666247680

When you write code for many moons, usually you will develop some sort of shared library/package for various projects.
These Python scripts may not be suitable for deployment as a package but you still want to use them anywhere.

Another issue is that I often need to write and run code cross platform/cluster. So I want to make sure there is an easy way to configure my code so that I don't have to modify things when I update something.

In my early attempt, I put everything into a package and use the following method to use them in any source code:

With these global variables, now I can import any function within the package:

This seems to work well at the beginning, however, I have to copy/paste this about 20 lines of code in lots of functions. And if I want to add new capability, I have to modify all of them!

So I am on a new quest to fix it.

After digging a little bit, I was a…