import from future

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lee

    #1

    import from future

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

  • Marc 'BlackJack' Rintsch

    #2
    Re: import from future

    In <1169969100.946 843.111770@p10g 2000cwp.googleg roups.com>, lee wrote:
    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_DIVI SION',
    'CO_GENERATOR_A LLOWED',
    'CO_NESTED',
    '_Feature',
    '__all__',
    '__builtins__',
    '__doc__',
    '__file__',
    '__name__',
    'all_feature_na mes',
    'division',
    'generators',
    'nested_scopes']

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

    In [5]: __future__.divi sion
    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

    Comment

    • Dan Bishop

      #3
      Re: import from future

      On Jan 28, 1:25 am, "lee" <libi...@gmail. comwrote:
      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.

      Comment

      • Marc 'BlackJack' Rintsch

        #4
        Re: import from future

        In <1170049392.204 148.54430@a34g2 000cwb.googlegr oups.com>, Dan Bishop
        wrote:
        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 `::
        >>__future__.wi th_statement
        _Feature((2, 5, 0, 'alpha', 1), (2, 6, 0, 'alpha', 0), 32768)

        Ciao,
        Marc 'BlackJack' Rintsch

        Comment

        • Peter Otten

          #5
          Re: import from future

          Marc 'BlackJack' Rintsch wrote:
          In <1170049392.204 148.54430@a34g2 000cwb.googlegr oups.com>, Dan Bishop
          wrote:
          >
          >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 `::
          ....and absolute_import .

          Peter


          Comment

          Working...