3

In the discussion from a question I asked several days ago (Using the processing framework in a PyQGIS standalone application), someone suggested that I use general.runalg() instead of processing.runalg() for running QGIS algorithms.

I've now used both, and haven't noticed a difference in either performance or syntax between them. I'm just wondering what sort of differences there are between these two methods, and which one I should be using.

1 Answer 1

4

Open a QGIS Python Console and run this:

import processing help( processing.runalg ) 

You will get:

Help on function runalg in module processing.tools.general: runalg(algOrName, *args, **kwargs) 

Which indicates us that by using processing.runalg(), you're actually calling general.runalg().

Note that if you want to call general.runalg() explicitly, you need to import the general module from processing.tools.

In summary, use whatever you want, just make sure you initialize Processing (Processing.initialize()) before calling runalg() if you're running a standalone PyQGIS script.

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.