You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from library1 import NUMBER as A
import library2 as B
C=B.SomethingClass()
print(A)
A=1.234
class A:
def __init__(A):A._name='something'
One workaround here is to always import things with from and do a hacky, fragile grep of that to produce symbols to be excluded using --preserve-globals.
I'm using this on some MicroPython code to squeeze it into a small file system on the micro:bit and apart from this and maybe some issues with MicroPython's special const() it works really well, thanks.
The text was updated successfully, but these errors were encountered:
This is expected, as python-minifier only work on a single module at a time. It doesn't track names across modules.
Using --rename-globals on a module is likely to break anything that imports it.
In this simple example, you could use --rename-globals for program.py, but not for the other files.
Minifying a whole program at a time would be a good enhancement.
Thanks, my workaround is based on this primitive rule in my Makefile which "parses" all the from style imports so I can then exclude them with --preserve-globals.
If you have multiple files with and
import
statements then--rename-globals
cannot be used.For the files program.py
and library1.py
and library2.py
these arguments
produce output that does not work.
One workaround here is to always import things with
from
and do a hacky, fragile grep of that to produce symbols to be excluded using--preserve-globals
.I'm using this on some MicroPython code to squeeze it into a small file system on the micro:bit and apart from this and maybe some issues with MicroPython's special
const()
it works really well, thanks.The text was updated successfully, but these errors were encountered: