Pywikibot/General basics/Invoking Python

< Pywikibot < General basics

Your bot should assume that it is multilingual. Because of that, use UTF-8 (or some better character set) and declare it at the beginning of your Python script:

#!/usr/bin/python
# -*- coding: utf-8 -*-

However, we will use Python interpreter for examples, invoked by simple typing "python". Interpreter doesn't require first two lines, but scripts written into a file have to have the first line and should have the second line.

If you are writing examples into the file and you want to execute it, you should choose one of two approaches:

$ chmod +x mybot.py

... after which you would be able to execute your script directly:

$ ./mybot.py
$ python mybot.py
This article is issued from Wikiversity - version of the Wednesday, November 11, 2015. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.