Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #47605

Re: py_compile vs. built-in compile, with __future__

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'expressions': 0.07; 'skip:p 60': 0.07; 'string': 0.09; 'parameter': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; '"__future__"': 0.16; '__future__': 0.16; 'ast': 0.16; 'byte-compile': 0.16; 'command-line': 0.16; 'mechanism.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'statements,': 0.16; 'wrote:': 0.18; 'command': 0.22; 'code,': 0.22; 'import': 0.22; 'header:User-Agent:1': 0.23; 'either.': 0.24; 'equivalent': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; "doesn't": 0.30; 'needed.': 0.30; 'statement': 0.30; "i'm": 0.30; 'bug?': 0.31; 'this.': 0.32; 'running': 0.33; 'subject:with': 0.35; 'there': 0.35; 'form,': 0.38; 'needed': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'future': 0.60; 'received:173': 0.61; 'design,': 0.64; 'subject:. ': 0.67; 'influence': 0.74; 'compiling': 0.84; 'received:fios.verizon.net': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Jan Reedy <tjreedy@udel.edu>
Subject Re: py_compile vs. built-in compile, with __future__
Date Mon, 10 Jun 2013 16:59:35 -0400
References <0bfe7bee-3df2-4fb8-8aad-c2124792b8b6@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host pool-173-75-251-66.phlapa.fios.verizon.net
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130509 Thunderbird/17.0.6
In-Reply-To <0bfe7bee-3df2-4fb8-8aad-c2124792b8b6@googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2987.1370897988.3114.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1370897988 news.xs4all.nl 15974 [2001:888:2000:d::a6]:47610
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:47605

Show key headers only | View raw


On 6/10/2013 11:33 AM, dhyams wrote:
> The built-in compile() function has a "flags" parameter that one can
> use to influence the "__future__" mechanism. However,
> py_compile.compile, which I'm using to byte-compile code, doesn't
> have an equivalent means to do this.

That flag was added to compile bacause it is needed to compile 
expressions and single statements, whether in string or ast form, that 
use future syntax. It is impossible to include a future statement with 
either. It is not needed for compiling multiple statements.

> Is this by design, or would this be considered a bug?

Design, not needed.

> import __future__
> py_compile.compile("foobar.py",flags=__future__.CO_FUTURE_DIVISION)

Put the future statement inside foobar.py just as you would do if 
running it from the command line. Notice that there is no command-line 
future flag either.

Terry


Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

py_compile vs. built-in compile, with __future__ dhyams <dhyams@gmail.com> - 2013-06-10 08:33 -0700
  Re: py_compile vs. built-in compile, with __future__ Terry Jan Reedy <tjreedy@udel.edu> - 2013-06-10 16:59 -0400
    Re: py_compile vs. built-in compile, with __future__ dhyams <dhyams@gmail.com> - 2013-06-10 15:27 -0700
      Re: py_compile vs. built-in compile, with __future__ Chris Angelico <rosuav@gmail.com> - 2013-06-11 08:36 +1000
        Re: py_compile vs. built-in compile, with __future__ dhyams <dhyams@gmail.com> - 2013-06-10 16:31 -0700
          Re: py_compile vs. built-in compile, with __future__ Neil Cerutti <neilc@norwich.edu> - 2013-06-11 15:37 +0000
            Re: py_compile vs. built-in compile, with __future__ dhyams <dhyams@gmail.com> - 2013-06-11 14:25 -0700
              Re: py_compile vs. built-in compile, with __future__ Neil Cerutti <neilc@norwich.edu> - 2013-06-12 13:30 +0000

csiph-web