Skip to content

Instantly share code, notes, and snippets.

@juancarlospaco
Created March 20, 2015 15:06
Show Gist options
  • Save juancarlospaco/50c8197abe543c9688a1 to your computer and use it in GitHub Desktop.
Save juancarlospaco/50c8197abe543c9688a1 to your computer and use it in GitHub Desktop.
How to know which __future__ to import
import __future__, sys
[name for name in __future__.all_feature_names if getattr(__future__, name).optional <= sys.version_info < getattr(__future__, name).mandatory]
@juancarlospaco
Copy link
Author

>>> import __future__, sys
>>> [name for name in __future__.all_feature_names if getattr(__future__, name).optional <= sys.version_info < getattr(__future__, name).mandatory]
['division', 'absolute_import', 'print_function', 'unicode_literals']
>>>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment