Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to activate __future__ features in embedded Python?

17 views
Skip to first unread message

Stefan Franke

unread,
Jan 29, 2002, 12:11:47 PM1/29/02
to
[sorry if this is a repost]

Doing

Py_Initialize();
PyRun_SimpleString("from __future__ import generators, division\n");

doesn't seem to affect subsequent PyRun_String() calls.


Michael Hudson

unread,
Jan 29, 2002, 12:33:28 PM1/29/02
to
Stefan Franke <fra...@ableton.com> writes:

> [sorry if this is a repost]

Don't think so.

> Doing
>
> Py_Initialize();
> PyRun_SimpleString("from __future__ import generators, division\n");
>
> doesn't seem to affect subsequent PyRun_String() calls.

You need PyRun_SimpleStringFlags.

Cheers,
M.

--
It's actually a corruption of "starling". They used to be carried.
Since they weighed a full pound (hence the name), they had to be
carried by two starlings in tandem, with a line between them.
-- Alan J Rosenthal explains "Pounds Sterling" on asr

Stefan Franke

unread,
Jan 30, 2002, 9:58:17 AM1/30/02
to
On Tue, 29 Jan 2002 17:33:28 GMT, Michael Hudson <m...@python.net>
wrote:
>
>You need PyRun_SimpleStringFlags.
>

Ahh, thanks. What I actually needed was PyRun_StringFlags on each
call.
Unluckily CO_GENERATOR_ALLOWED and CO_FUTURE_DIVISION
are not declared publically by Python.h.

Stefan

Michael Hudson

unread,
Jan 30, 2002, 10:19:01 AM1/30/02
to
Stefan Franke <fra...@ableton.com> writes:

> Unluckily CO_GENERATOR_ALLOWED and CO_FUTURE_DIVISION
> are not declared publically by Python.h.

Really? Oh well. They're in compile.h, or you could call

PyRun_SimpleStringFlags("from __future__ import whatever", &flags);

and then reuse the same flags for every call (I think this will work,
not sure sorry).

Cheers,
M.

--
I also feel it essential to note, [...], that Description Logics,
non-Monotonic Logics, Default Logics and Circumscription Logics
can all collectively go suck a cow. Thank you.
-- http://advogato.org/person/Johnath/diary.html?start=4

0 new messages