I defined a data class which has a few fields. When I print it, they are displayed in the correct order:
def test():
@dataclass
class Image:
width: int
height: int
pixels: object
image = Image(width=4, height=3, pixels=list(range(12)))
print(image)
pass
The output of this code is good:
test.<locals>.Image(width=4, height=3, pixels=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
But if I examine the variable in PyCharm (by stopping at a breakpoint at the last line, which says pass
), it shows me the fields in alphabetical order, which is confusing:
Can I fix this behavior?
I am using PyCharm 2019.1.2.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…