[Scons-dev] no more print statements in SConscripts?
Bill Deegan
bill at baddogconsulting.com
Wed May 25 17:38:23 EDT 2016
Tim,
Here's the implementation:
https://bitbucket.org/scons/scons/src/1e0827962a2bb114041df47d44be2384c86f3918/src/engine/SCons/Script/SConscript.py?at=default&fileviewer=file-view-default#SConscript.py-251
Basically it exec()'s the SConscript as follows:
exec(compile(_file_.read(), _file_.name,
'exec'), call_stack[-1].globals)
So given that print_function() is already imported from __future__ at
that point I don't think we can do a per SConscript exclusion?
-Bill
On Wed, May 25, 2016 at 11:19 AM, Tim Jenness <tjenness at lsst.org> wrote:
>
> > On May 25, 2016, at 11:16 , Bill Deegan <bill at baddogconsulting.com>
> wrote:
> >
> > I think this is a python global flag isn't it?
> > I don't think you can turn it on and off selectively?
> >
>
> It’s per file. If you add
>
> from __future__ import print_function
>
> at the top of your file that file will have print(). Without it the print
> will be a statement. What you can’t do is change print from a statement to
> a function or vice versa in the middle of a file (so that __future__ import
> must be at the top of the file).
>
> I don’t really know how SConstruct files are imported so it may be that
> there is something about the importing that inherits the print_function
> state of the code doing the reading of the file (are they read and then
> evaled?). If they are read and then the string evaluated that might explain
> the problem. If they are imported with importlib then I’m confused.
>
> —
> Tim Jenness
> _______________________________________________
> Scons-dev mailing list
> Scons-dev at scons.org
> https://pairlist2.pair.net/mailman/listinfo/scons-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/scons-dev/attachments/20160525/2272e511/attachment-0001.html>
More information about the Scons-dev
mailing list