Posts

Identify the non-finite verbs [on hold]

Image
-4 a) I must stop giving advice to everyone. b) Hearing the knock on the door, she ran to open it. c) He remained inside the burning house to rescue all the children. past-participle non-finite-verbs share | improve this question asked 18 hours ago Bhavna Khanna 1 New contributor Bhavna Khanna is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct. ...

better hexdump with join?

Image
0 This is some code which prints a hexdump of a list of 16 bit numbers, at 16 bytes distance for each, after the "print data" comment: #!/usr/bin/python3 # creating test data data = for i in range(500): data = data + [ i & 0xff, i >> 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] # print data c = 0 out = "" for i in range(int(len(data) / 16)): if i == 512: break low = data[i * 16] high = data[i * 16 + 1] d = low | (high << 8) out = out + ("%04x " % d) if (i % 16) == 15: out = out + "n" print(out) It works, but I think I can write it simpler with "join" and maybe list comprehension? But shouldn't be a cryptic one-liner or something, I'm just looking for a more idiomatic Python solution. I want to prin...