Skip to content

Commit 0321d79

Browse files
renepickhardtcdecker
authored andcommitted
[plugin] Improved the example code to encourage usage of optional arguments (#2212)
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
1 parent 3aecede commit 0321d79

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

contrib/plugins/helloworld.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
@plugin.method("hello")
9-
def hello(name, plugin):
9+
def hello(plugin, name="world"):
1010
"""This is the documentation string for the hello-function.
1111
1212
It gets reported as the description when registering the function
@@ -25,12 +25,12 @@ def init(options, configuration, plugin):
2525

2626

2727
@plugin.subscribe("connect")
28-
def on_connect(id, address, plugin):
28+
def on_connect(plugin, id, address):
2929
plugin.log("Received connect event for peer {}".format(id))
3030

3131

3232
@plugin.subscribe("disconnect")
33-
def on_disconnect(id, plugin):
33+
def on_disconnect(plugin, id):
3434
plugin.log("Received disconnect event for peer {}".format(id))
3535

3636

0 commit comments

Comments
 (0)