When setting default encoding to UTF-8 in Google App Engine, do I have to set it in all python files?

StackOverflow https://stackoverflow.com/questions/23428288

Question

I got this code in this answer: Set Python27 Google AppEngine default encoding for entire app

#!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

Do I have to do this just in main.py (file with request handlers) or to every single python file that I create?

Was it helpful?

Solution

Yes, like the from __future__ import line the # coding line only ever applies to the file it is placed in.

Python uses it when compiling the source file to bytecode, and you are free to use different encodings for different source files should you so wish.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top