import from future

L

lee

what are the things that we can do with import from future usage.....i
heard its very interesting......thanks
 
M

Marc 'BlackJack' Rintsch

what are the things that we can do with import from future usage.....i
heard its very interesting......thanks

Here's how to find out yourself (done with a 2.4 release):

In [2]: import __future__

In [3]: dir(__future__)
Out[3]:
['CO_FUTURE_DIVISION',
'CO_GENERATOR_ALLOWED',
'CO_NESTED',
'_Feature',
'__all__',
'__builtins__',
'__doc__',
'__file__',
'__name__',
'all_feature_names',
'division',
'generators',
'nested_scopes']

In [4]: __future__.all_feature_names
Out[4]: ['nested_scopes', 'generators', 'division']

In [5]: __future__.division
Out[5]: _Feature((2, 2, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 8192)

In [6]: help(__future__)
<snipped help output>

Ciao,
Marc 'BlackJack' Rintsch
 
D

Dan Bishop

what are the things that we can do with import from future usage.....i
heard its very interesting......thanks

Now that nested_scopes and generators are no longer optional, the only
thing left is "from __future__ import division", which makes the "/"
operator on integers give the same result as for floats.
 
M

Marc 'BlackJack' Rintsch

Dan Bishop said:
Now that nested_scopes and generators are no longer optional, the only
thing left is "from __future__ import division", which makes the "/"
operator on integers give the same result as for floats.

From 2.5 on we have `with_statement`::
_Feature((2, 5, 0, 'alpha', 1), (2, 6, 0, 'alpha', 0), 32768)

Ciao,
Marc 'BlackJack' Rintsch
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top