Sujet : Re: Command Languages Versus Programming Languages
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.unix.shell comp.unix.programmer comp.lang.miscDate : 09. Apr 2024, 09:38:02
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <uv2upa$42fo$2@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
User-Agent : Pan/0.155 (Kherson; fc5a80b8)
On Tue, 9 Apr 2024 10:11:09 +0200, David Brown wrote:
Comments to say when your loop or functions end is another big red flag
that the layout is bad.
Without #end comments: how easy is it to tell which lines belong to
the inner function, and which to the outer?
def set_message(self, message) :
w_self = weak_ref(self)
def wrap_message(c_conn, c_message, c_user_data) :
self = _wderef(w_self, "vtable")
conn = Connection(dbus.dbus_connection_ref(c_conn))
msg = Message(dbus.dbus_message_ref(c_message))
user_data = conn._user_data.get(c_user_data)
result = message(conn, msg, user_data)
if asyncio.iscoroutine(result) :
self.create_task(result)
result = DBUS.HANDLER_RESULT_HANDLED
return \
result
if message != None :
self._wrap_message_func = DBUS.ObjectPathMessageFunction(wrap_message)
else :
self._wrap_message_func = None
self._dbobj.message_function = self._wrap_message_func
return \
self
Now, with #end comments (and a #begin as well, for good measure):
def set_message(self, message) :
w_self = weak_ref(self)
def wrap_message(c_conn, c_message, c_user_data) :
self = _wderef(w_self, "vtable")
conn = Connection(dbus.dbus_connection_ref(c_conn))
msg = Message(dbus.dbus_message_ref(c_message))
user_data = conn._user_data.get(c_user_data)
result = message(conn, msg, user_data)
if asyncio.iscoroutine(result) :
self.create_task(result)
result = DBUS.HANDLER_RESULT_HANDLED
#end if
return \
result
#end wrap_message
#begin set_message
if message != None :
self._wrap_message_func = DBUS.ObjectPathMessageFunction(wrap_message)
else :
self._wrap_message_func = None
#end if
self._dbobj.message_function = self._wrap_message_func
return \
self
#end set_message