Important questions about __future__

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu Jan 3 11:20:47 CET 2013


On Thu, 03 Jan 2013 03:27:42 -0600, Andrew Berg wrote:

> Does 'from __future__ import barry_as_FLUFL' do anything? 

Yes, it re-enables <> and disables != as not equal:

py> sys.version
'3.3.0rc3 (default, Sep 27 2012, 18:44:58) \n[GCC 4.1.2 20080704 (Red Hat 
4.1.2-52)]'
py> 1 <> 2
  File "<stdin>", line 1
    1 <> 2
       ^
SyntaxError: invalid syntax
py> from __future__ import barry_as_FLUFL
py> 1 <> 2
True


> Where is
> 'from __future__ import braces' implemented in CPython (it's not in
> __future__.py)?

It's defined in the C source code for the CPython compiler. Look in 
future.c.

http://hg.python.org/cpython/file/944e86223d1f/Python/future.c




-- 
Steven



More information about the Python-list mailing list