From: "Guido van Rossum" <guido@digicool.com> > > > > Very good idea IMO, but 'if 0:' is optimized away. > > > > > > I'm not sure I understand. freeze does not optimize away such a code > > > block. Under which condition is that optimized away? > > > > > The Python compiler itself. 'if 0: import whatever' does > > not generate any byte code. Modulefinder (used by freeze, > > py2exe, and Gordon's installer) checks the compiled byte code > > for import statements. > > Good catch, Thomas. > > I find defining a variable _FAKE a bit cumbersome as a work-around. I > would suggest instead: > > if 1==0: > import whatever > > since the optimizer only optimizes out "if 0:". If the optimizer becomes more intelligent in the future, and also probably easier to document the purpose would be to use an (uncalled) function: def _freeze_hints(): import spam Just another idea, Thomas
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4