On 14/07/13 09:29, Jim Mooney wrote:

Which  brings up a question. I  finally settled on Python 2.7 for various
reasons, but find some 3.3 things useful. Generators are one-off and input
is one-off, so they match well for testing, for instance.

I don't understand that last sentence.


I checked the
docs and I don't see many __future__ imports. Are these all there are, or
are there other useful ones that are better hidden?

Try this one:

from __future__ import braces



-  nested_scopes,
generators, division, absolute_import, with_statement print_function
unicode_literals

As of Python 3.3, the full list of __future__ imports are:

py> import __future__
py> __future__.all_feature_names
['nested_scopes', 'generators', 'division', 'absolute_import', 
'with_statement', 'print_function', 'unicode_literals', 'barry_as_FLUFL']


__future__ features will never be removed, even when they no longer have an effect. For 
example, nested scopes have become standard since Python 2.2, but "from __future__ 
import nested_scopes" will be legal (and a no-op) so long as Python exists.

There may be new __future__ features in the future. For example, I wouldn't be surprised 
if Python 3.5 or 3.6 introduces "from __future__ import decimal_literals" or 
some such thing.


I'm not importing them all, just what seems useful to me at this point, and
renaming raw_input, so my 2.7 is kind of 3.3ish. But is there anything I
missed or any problems I'm unaware of in what will be my standard header,
below?

#Using Python 2.7 on Win 7
from __future__ import generators, division, with_statement, print_function
import sys
if int(sys.version[0]) < 3: input = raw_input

You don't need generators in 2.7, they have been standard since Python 2.4.



--
Steven
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to