Archive
Posts Tagged ‘__future__’
2014: moving towards Python 3
January 3, 2014
Leave a comment
My new year’s resolution is to move (slowly) towards Python 3. I don’t want to switch yet but I will use things in my code that will facilitate the transition in the future. Thus, from now on I will use this skeleton for my new scripts:
#!/usr/bin/env python
# encoding: utf-8
from __future__ import (absolute_import, division,
print_function, unicode_literals)
def main():
pass
####################
if __name__ == "__main__":
main()
“A future statement must appear near the top of the module. The only lines that can appear before a future statement are:
- the module docstring (if any),
- comments,
- blank lines, and
- other future statements.“
More info on the __future__ imports
Compatibility layers
Categories: python
absolute import, division, print function, python3, unicode literals, __future__
