[ python-Bugs-1385055 ] execfile anomaly with "from __future__ import division"

SourceForge.net noreply at sourceforge.net
Wed Dec 21 06:53:34 CET 2005


Bugs item #1385055, was opened at 2005-12-19 02:15
Message generated for change (Settings changed) made by nnorwitz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1385055&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.4
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: Harri Pasanen (harripasanen)
Assigned to: Nobody/Anonymous (nobody)
Summary: execfile anomaly with "from __future__ import division"

Initial Comment:
If I have a file init.py with two lines: 
 
from __future__ import division 
print 3/4 
 
and I do  
 
[harri at dell-harri tests]$ python 
Python 2.4 (#1, Feb 16 2005, 01:23:25) 
[GCC 3.4.3 (Mandrakelinux 10.0 3.4.3-2mdk)] on linux2 
Type "help", "copyright", "credits" or "license" for 
more information. 
>>> execfile('init.py') 
0.75 
>>> 3/4 
0 
 
I would have expected the latter to return 0.75 as 
well. 
 
Due to this it seems impossible to provide init code 
that would initialize the interactive prompt to 
future division behaviour. 
 
The same applies to exec statement. 
 
I'm not sure if this is bug, or an unfortunate 
feature.  The documention is not very clear on this 
issue. 
 
-Harri 

----------------------------------------------------------------------

>Comment By: Neal Norwitz (nnorwitz)
Date: 2005-12-20 21:53

Message:
Logged In: YES 
user_id=33168

Closing per your request.  I don't see any particularly good
place in the doc to add a comment.  I agree a comment about
-Qnew wouldn't hurt.

----------------------------------------------------------------------

Comment By: Harri Pasanen (harripasanen)
Date: 2005-12-19 02:42

Message:
Logged In: YES 
user_id=77088

Looks like this is a duplicate of  
[ 567568 ] future division broken w/ PYTHONSTARTUP 
http://sourceforge.net/tracker/?group_id=5470&atid=105470&func=detail&aid=567568 
 
As I suspected, it is an unfortunate feature. Tim's 
explication provides the missing documentation.  And I 
assume the exec statement provides its own anonymous 
module. 
 
Btw. where is the -Qnew documented?  from __future__ 
division docs should carry a pointer to it. 
 
Here is another thread on the subject in the ipython 
mailing list: 
 
http://scipy.net/pipermail/ipython-user/2005-December/001183.html 
 
This can be closed. 
 
-Harri 
 

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1385055&group_id=5470


More information about the Python-bugs-list mailing list