Comments by "Lawrence D’Oliveiro" (@lawrencedoliveiro9104) on "ArjanCodes"
channel.
-
33
-
11
-
10
-
8
-
8
-
6
-
6
-
5
-
5
-
5
-
4
-
4
-
4
-
4
-
3
-
3
-
3
-
3
-
3
-
3
-
2
-
2
-
2
-
2
-
2
-
I notice you only talked about function decorators, not class decorators. They have their uses, too.
I think the most extensive use I have made of custom decorators so far has been in my DBussy package, a pure-Python wrapper for libdbus. The information defining the D-Bus interface to a Python class is specified via a function decorator on each Python method implementing a D-Bus interface method, with a class decorator to tie it all together. Then when you register your class to receive messages, the dispatch mechanism knows how to decode incoming D-Bus method calls, convert the arguments and dispatch to the appropriate Python method.
As a bonus, this same information is used to automatically generate the D-Bus XML introspection format, when another D-Bus peer sends you the introspection message. And conversely, when you introspect another D-Bus peer, this info is used to dynamically generate a “proxy interface class” -- a Python class whose methods simply send the appropriate D-Bus messages and return the responses.
2
-
2
-
2
-
2
-
2
-
2
-
2
-
2
-
2
-
2
-
2
-
2
-
2
-
2
-
2
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1