Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.erje.net!eu.feeder.erje.net!news-1.dfn.de!news.dfn.de!news.informatik.hu-berlin.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Neil Cerutti Newsgroups: comp.lang.python Subject: Re: py_compile vs. built-in compile, with __future__ Date: 11 Jun 2013 15:37:17 GMT Organization: Norwich University Lines: 14 Message-ID: References: <0bfe7bee-3df2-4fb8-8aad-c2124792b8b6@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: individual.net GZARND24jQuvYtTTO6FDuA/xdEaujDLGD/P98oLUWBRBywzHuq Cancel-Lock: sha1:se7Ya8qLhBKuMmEmQpC4p1EM5u8= User-Agent: slrn/0.9.9p1/mm/ao (Win32) Xref: csiph.com comp.lang.python:47667 On 2013-06-10, dhyams wrote: > On Monday, June 10, 2013 6:36:04 PM UTC-4, Chris Angelico wrote: >> Can you read the file into a string, prepend a future directive, and >> >> then compile the string? > > Technically yes, except that now there is complication of > writing the modified module back to a file so that I can still > use py_compile.compile() to byte compile that code. You would use StringIO instead of writing a temp file. -- Neil Cerutti