2 starting comments for a python script

Every python script should start with 2 lines in comment. These will define important aspects of your script's behaviour.

#!/usr/bin/python
# -*- coding: utf-8 -*-
The shebang on the first line makes the script executable as a shell script (= you can execute the script without having to type "python" in front of its filename).

The next line sets the default character set for your script. All string literals inside your script will be interpreted according to this character set. Since we are using utf-8, we can write string literals with unicode characters inside of them.

Comments

Popular posts from this blog

Handling control characters (escaping) in python for json and mysql

python port sniffer with pcapy and impacket

Django field, form and model validation process