I discovered that a print statement using newline suppression (end=’ ') is in a function the newline suppression does not work. If the same code is placed inline (in main), it works properly. Anyone ever come across this? Using Python 3.12.
Here is some example code:
tprint("\nHex Buffer Dump")
src_list = [128, 192, 64, 228, 32, 244, 16, 0, 8, 156, 4, 15, 53, 23, 12, 255]
data = bytes(src_list)
def dump_buff(buff):
j = 0;
for i in range(len(buff)):
print("{:02X}".format(buff[i]), end=' ')
j += 1
if j == 8:
j = 0
print()
print()
# test code inline
print("\nCode inline")
j = 0
for i in range(len(data)):
print("{:02X}".format(data[i]), end=' ')
j += 1
if j == 8:
j = 0
print()
# test when code in function
print("\nCode in function")
dump_buff(data)ype or paste code here
Here is what output looks like:
Hex Buffer Dump
Code inline (works as expected)
80 C0 40 E4 20 F4 10 00
08 9C 04 0F 35 17 0C FF
Code in function (new line suppression not honored)
80
C0
40
E4
20
F4
10
00
08
9C
04
0F
35
17
0C
FF