From 8854c9b4b4a22d5d01af90eae4ca469d187ebdb6 Mon Sep 17 00:00:00 2001 From: Rene Pickhardt Date: Wed, 2 Jan 2019 11:53:22 +0100 Subject: [PATCH 1/2] improved the example code to encourage usage of optional arguments The example code had the `plugin` argument as the last argument. this disallows arguments that have a standard value. As far as I understand the dispatching code the order of arguments does not matter since it is the name `plugin` that is relevant. Therefor I changed the order so that newbe's don't have to read the entire code and can easily add optional arguments --- contrib/plugins/helloworld.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/plugins/helloworld.py b/contrib/plugins/helloworld.py index dcc329ca6470..60a6d16cad55 100755 --- a/contrib/plugins/helloworld.py +++ b/contrib/plugins/helloworld.py @@ -6,7 +6,7 @@ @plugin.method("hello") -def hello(name, plugin): +def hello(plugin,name = "world"): """This is the documentation string for the hello-function. It gets reported as the description when registering the function @@ -25,12 +25,12 @@ def init(options, configuration, plugin): @plugin.subscribe("connect") -def on_connect(id, address, plugin): +def on_connect(plugin, id, address): plugin.log("Received connect event for peer {}".format(id)) @plugin.subscribe("disconnect") -def on_disconnect(id, plugin): +def on_disconnect(plugin, id): plugin.log("Received disconnect event for peer {}".format(id)) From 4db3f476afb20523ca00733579cd272dedda1043 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Wed, 2 Jan 2019 18:26:22 +0100 Subject: [PATCH 2/2] Update contrib/plugins/helloworld.py added small stylistic fix by @cdecker (sorry I made that original fix also on the github editor which did not have autosave actions) Co-Authored-By: renepickhardt --- contrib/plugins/helloworld.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/plugins/helloworld.py b/contrib/plugins/helloworld.py index 60a6d16cad55..3e0e22cb0a93 100755 --- a/contrib/plugins/helloworld.py +++ b/contrib/plugins/helloworld.py @@ -6,7 +6,7 @@ @plugin.method("hello") -def hello(plugin,name = "world"): +def hello(plugin, name="world"): """This is the documentation string for the hello-function. It gets reported as the description when registering the function