[Python-bugs-list] [ python-Bugs-567568 ] future division broken w/ PYTHONSTARTUP
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 11 Jun 2002 14:06:51 -0700
Bugs item #567568, was opened at 2002-06-11 12:38
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=567568&group_id=5470
Category: Parser/Compiler
Group: Python 2.2.1
Status: Closed
Resolution: Invalid
Priority: 5
Submitted By: TEd Drain (teddrain)
Assigned to: Nobody/Anonymous (nobody)
Summary: future division broken w/ PYTHONSTARTUP
Initial Comment:
Version: 2.2.1
Compiler: gcc 2.95.3
Platform: linux (2.4 kernel)
If I create a file startup.py:
from __future__ import division
a = 1/2
print a
then setenv PYTHONSTARTUP startup.py
and launch python, it prints 0.5 like it should and the
variable a is available to me. But, the future
division is not propagated to the interpreter.
~: setenv PYTHONSTARTUP startup.py
~: python
Python 2.2.1 (#1, May 16 2002, 16:10:22)
[GCC 2.95.3 20010315 (release)] on linux2
Type "help", "copyright", "credits" or "license" for
more information.
0.5
>>> print a
0.5
>>> 1/2
0
It looks like the compiler flags from the PYTHONSTARTUP
file are not be passed to the interpreter.
----------------------------------------------------------------------
>Comment By: TEd Drain (teddrain)
Date: 2002-06-11 14:06
Message:
Logged In: YES
user_id=561567
The problem with the statement is that the startup script is
NOT a separate module. If it was, variables defined in it
and modules (other that future) would not be in the main
interpreter module when I startup.
It's very confusing to me that if I add 'import sys' to the
startup script, it will make the sys module available
automatically. So this means import future has a different
behavior than any other import. Why should import future
behave completely differently that import module or variable
declarations? I think it would make a lot more sense if
import behaved the same regardless of the arguments in the
startup script.
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2002-06-11 13:56
Message:
Logged In: YES
user_id=31435
Not a bug. All .py files are distinct modules, whether or not
run at startup, and the effect of a future statement is
limited to the module in which it appears. There is no way
to make a future statement (division or otherwise) apply
globally.
For the specific case of future division, you can try the
experimental -Qnew command-line argument. As the PEP
says, this isn't recommended yet, but I do it <wink>.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=567568&group_id=5470