Reputation: 71
I want to release a subset of my code for external use. Only certain functions or methods should be used (or even seen) by the external customer. Is there a way to do this in Python?
I thought about wrapping the code I want removed in an if __debug__:
and then creating a .pyc file with py_compile
or compileall
and then recreate source code from the new byte-code using uncompyle2
. The __debug__
simply creates an if False
condition which gets stripped out by the "compiler". I couldn't figure out how to use those "compiler modules" with the -O
option.
Upvotes: 3
Views: 178
Reputation: 3635
I don't know if there are any standard tools for doing this, but it shouldn't be too difficult to mark the sections with appropriately coded remarks and then run all your files through a script that outputs a new set of files omitting the lines between those remarks.
Upvotes: 1