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


Groups > comp.lang.python > #47609

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

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.106
X-Spam-Level *
X-Spam-Evidence '*H*': 0.79; '*S*': 0.00; 'python': 0.11; '"from': 0.16; '__future__': 0.16; 'directive': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'write.': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'import': 0.22; 'mathematical': 0.24; 'string,': 0.24; 'file.': 0.24; 'source': 0.25; 'switch': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'especially': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'mod': 0.31; 'file': 0.32; 'guess': 0.33; 'subject:with': 0.35; 'agree': 0.35; 'common': 0.35; 'possible.': 0.35; 'received:google.com': 0.35; "i'll": 0.36; 'should': 0.36; 'effort': 0.37; 'to:addr:python-list': 0.38; 'little': 0.38; 'to:addr:python.org': 0.39; 'read': 0.60; 'future': 0.60; 'matter': 0.61; 'situation': 0.65; 'subject:. ': 0.67; 'fails,': 0.84; 'idiot-proof': 0.84; 'plugins': 0.84; 'mistake': 0.91; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=vu+ZFevW2FIEOvqB1xNQRaJ5yjJLDyTAVPrCTEppT4M=; b=Q6bIjeFfc4lZDJU8Dpbm6am+tcFgVq4LkCKVLjssOb/VLmyOukoJShPX+sZDGNl1Gf Zywr9TBAzCGD3MVGq3cZaMy0f5akqmXtBWVDSX/H19JvxjVxkVVulVnUeLx7goqTD0iO lusAQnSJhj4pTyYPq0UA4i1DFJx1zvQ13P2+4QMKfI/JBBPzk5nqP2ZlAMi8BF21WeVh lHzdoV8NeL9P2fTQqZZxXsMx7b0WnTZmp7iz4R7ARJ9+uCAtVhseSd8w7fSg97lhvDNg 6yPTUhfBaPRDmUjHZRLemzRC0wsXDQcqJS88SWxZM4hp8ZPxyx8qKoC8E4ZX+jFLH41G DiZw==
MIME-Version 1.0
X-Received by 10.220.215.73 with SMTP id hd9mr7020223vcb.19.1370903764197; Mon, 10 Jun 2013 15:36:04 -0700 (PDT)
In-Reply-To <a0902635-60ca-4c93-a296-88f1740ac8fe@googlegroups.com>
References <0bfe7bee-3df2-4fb8-8aad-c2124792b8b6@googlegroups.com> <mailman.2987.1370897988.3114.python-list@python.org> <a0902635-60ca-4c93-a296-88f1740ac8fe@googlegroups.com>
Date Tue, 11 Jun 2013 08:36:04 +1000
Subject Re: py_compile vs. built-in compile, with __future__
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
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.2990.1370903766.3114.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1370903766 news.xs4all.nl 15881 [2001:888:2000:d::a6]:44371
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:47609

Show key headers only | View raw


On Tue, Jun 11, 2013 at 8:27 AM, dhyams <dhyams@gmail.com> wrote:
> I guess I'll have to agree to disagree here...the situation I'm in is that I want a user to be able to write a mathematical plugin with as little effort as possible.  So I want the "from __future__ import division" to be baked into the plugin, without have to require the user to put that bit of confusingness at the top of every plugin they write.  It's a matter of elegance to the end-user, especially because I want to make the plugins as idiot-proof as I can.  It will be common for a user not familiar with python to make the common 1/2 mistake (vs. 1.0/2.0).
>
> Is that not a reasonable use-case?

Can you read the file into a string, prepend a future directive, and
then compile the string?

Alternatively, can you switch to Python 3, where the future directive
isn't necessary? :)

If all else fails, you should be able to just copy and mod the
function into your own source file.

ChrisA

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