How to write a file code template in Pycharm

To add utf-8 compatibility in all your scripts, one solution is enable a template that add this compatibility and other information as copyright, your name, etc.
File and code templates are written in the Velocity Template Language (VTL). So you may include variables as ${YEAR}, ${USER}, etc.
To add code to your scritps go to File/Settings.../Editor/File and Code Templates
Select Python Script and add the following lines:

#!/usr/bin/env python2
# -*- coding: utf-8 -*-
# Copyright (C) ${YEAR} ${USER}



Now, if you create a new Python file, it will generate with this header code by default.
If you want more VTL variables please go here
Enjoy it!

Comments

Popular posts from this blog

from: can't read /var/mail/ in Python scripts

Fix "Set scan parameters failed: Input/output error" on Ubuntu 16.04

How to install a WhatsApp bot based on Python