First of all I understand the double hash (##) is used to define the Inputs / Outputs in a script's GUI. If there's more to it than that please let me know.

In all other Python coding I've done double hashes are just another variation on the single hash (meant for comments).

Can anyone provide background information into how QGIS manages to not see a ## line as an unexecuted comment?

I assume it's simply built into the QGIS Python compiler to recognize ## as defining GUI inputs & outputs.

Again I understand it now, and bottom line is it works, but it struck me as an odd way to set the GUI. Just curious.

1 Answer 1


A large part of QGIS is in C++, but surprisingly large amounts are also written in Python, including Processing. Processing is technically a Python plugin, although it's been 'brought into core' - made into a standard feature.

You can see the line in question in /python/plugins/processing/script/ScriptAlgorithm.py

def defineCharacteristicsFromFile(self):
    ... snip ...
    while line != '':
        if line.startswith('##'):
    ... snip ...

This code scans through the python file, looking for parameters and parsing those lines. As they're comments, python will ignore them - it's this script which gives them meaning.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.