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__

References <0bfe7bee-3df2-4fb8-8aad-c2124792b8b6@googlegroups.com> <mailman.2987.1370897988.3114.python-list@python.org> <a0902635-60ca-4c93-a296-88f1740ac8fe@googlegroups.com>
Date 2013-06-11 08:36 +1000
Subject Re: py_compile vs. built-in compile, with __future__
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.2990.1370903766.3114.python-list@python.org> (permalink)

Show all headers | 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