As I understand, when a line is received, it is passed to the callback function
if not self._connected:
raise ConnectionError("not connected to a server")
line = b''
while True:
try:
for line in self._socket_readlines(blocking):
if line[0:1] != b'#':
if raw:
callback(line)
else:
callback(self._parse(line))
How do I send the dictionary produced by:
callback(self._parse(line))
from
def callback(packet):
print(packet)
outside of the local scope of the callback function? Every time I have tried, I come up with empty sets. I don't know what I am doing wrong. Here is a snippet of the code I used:
packet_list = []
def callback(packet):
packet = list(packet) # I would like the whole packet, outside of this function
packet_list.append(packet)
return packet_list
but when I print the n-th term of the packet, I get nothing.
As I understand, when a line is received, it is passed to the callback function
How do I send the dictionary produced by:
callback(self._parse(line))
from
outside of the local scope of the callback function? Every time I have tried, I come up with empty sets. I don't know what I am doing wrong. Here is a snippet of the code I used:
but when I print the n-th term of the packet, I get nothing.