Hi Frank, thanks for your answer! Yes looks like there is no other way but passing empty strings. That’s what I wanted to avoid but anyway.
Regards Benjamin -----Ursprüngliche Nachricht----- Von: Frank Broniewski [mailto:[email protected]] Gesendet: Freitag, 9. März 2018 11:25 An: Fuenfer-Koenigstein.Benjamin extern IT-LN; [email protected] Betreff: AW: QGIS custom python function with zero or more args Hi Benjamin, I don't have a recipe for no argument, but you can pass an empty string as a workaround: @qgsfunction(args="auto", group="Custom") def myfunc(value, feature, parent): if not value: value = "Wert" return value Dipl. Geogr. Frank Broniewski Waldhölzbacher Str. 51 66679 Losheim am See 06872 509 068 4 0176 611 26 9 2 6 www.frankbroniewski.com -----Ursprüngliche Nachricht----- Von: Qgis-user <[email protected]> Im Auftrag von [email protected] Gesendet: Freitag, 9. März 2018 09:19 An: [email protected] Betreff: [Qgis-user] QGIS custom python function with zero or more args Hi all, I would like to write a custom python function for QGIS 2.18 that takes zero or one argument. The reason is that in most cases I can use a default value in the function, in some cases I would like to enter the value as argument. For python I know that you can prefix args in functions to make them optional, e.g. def func(*arg). For QGIS functions this will not work because there always have to be the args feature and parent in last two positions. Has anyone experience with QGIS functions that take zero or more arguments? Thanks for any help! Regards Benjamin _______________________________________________ Qgis-user mailing list [email protected] List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user _______________________________________________ Qgis-user mailing list [email protected] List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
