[IronPython] __future__ is a little too magic for its own good

Milind Chabbi t-milich at microsoft.com
Wed Jul 26 20:19:26 CEST 2006


Hi Jonathan,

You may be getting this error because you do not have __future__.py in
the path.

See the following examples:

1. When you do not have __future__.py

C:\ip2\IronPython\Public\Src\Test>ip
IronPython 1.0.2396 on .NET 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
>>> from __future__ import division
Traceback (most recent call last):
  File , line 0, in <stdin>##1
  File , line 0, in __import__##5
ImportError: No module named __future__




2. create a file __future__.py with content below( or use the attached
one):
division=1
with_statement=1


now, invoke ironpython

C:\ip2\IronPython\Public\Src\Tests>ip
IronPython 1.0.2396 on .NET 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
>>> from __future__ import division
>>> #you still can not import with_statement since it is Python25
feature
>>> from __future__ import with_statement
Traceback (most recent call last):
SyntaxError: future feature is not defined: with_statement (<stdin>,
line 1)


You still get error for with_statement because, it is enabled only with 
-X:Python25 switch.

3. Now invoke ironpython with -X:Python25 and you can import
with_statement also.

C:\ip2\IronPython\Public\Src\Tests>ip -X:Python25
IronPython 1.0.2396 on .NET 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
>>> from __future__ import with_statement
>>> 


Hope this helps.

Thanks

-----Original Message-----
From: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] On Behalf Of Jonathan Jacobs
Sent: Wednesday, July 26, 2006 1:44 AM
To: IronPython List
Subject: [IronPython] __future__ is a little too magic for its own good

IronPython 1.0.60725 on .NET 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
 >>> with
Traceback (most recent call last):
   File , line 0, in <stdin>##3
NameError: name 'with' not defined
 >>> from __future__ import with_statement
Traceback (most recent call last):
   File , line 0, in <stdin>##4
   File , line 0, in __import__##8
ImportError: No module named __future__
 >>> with
Traceback (most recent call last):
SyntaxError: unexpected token <eof> (<stdin>, line 1)

This appears to happen with every other __future__ import I tried.

P.S. Icons! Wheeeeee!!!
-- 
Jonathan
_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: __future__.py
Type: application/octet-stream
Size: 28 bytes
Desc: __future__.py
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20060726/8c4e036c/attachment-0001.obj>


More information about the Ironpython-users mailing list