The Full Wiki

More info on Pywikipediabot/General basics/Invoking Python

Pywikipediabot/General basics/Invoking Python: Wikis

Advertisements

Note: Many of our articles have direct quotes from sources you can cite, within the Wikipedia article! This article doesn't yet, but we're working on it! See more info or our list of citable articles.

Study guide

Up to date as of January 14, 2010

From Wikiversity

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:

  • You may give to your file executable mode (you need to do that only once!):
$ chmod +x mybot.py

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

$ ./mybot.py
  • Or you may invoke scripts by typing "python" before them:
$ python mybot.py

Advertisements






Got something to say? Make a comment.
Your name
Your email address
Message