Can a from __future__ import … guarantee Python 2 and 3 compatibility?
问题 I'm not interested in warming up the "Python 2 or Python 3?" questions (even though the most recent one I found is over one year old), but I stumbled upon this claim: You can write the Python 3 code under Python 2 if your file begins with the line: from __future__ import absolute_import, division, generators, unicode_literals, print_function, nested_scopes, with_statement With that line in place, your code will work with either Python 2 or Python 3. There may be rare cases in which it doesn't