Missing output when printing long lines from Python script

When I run the following snippet from the Macro window:

print("abcdefghijklmnopqrstuvwxyz" + 14000*"O")

the first 12 characters (“abcdefghijkl”) are missing. Does anybody know what is going on?

Obviously this is a contrived example. It was contrived from my very real script where i was printing out a datastructure to debug it, and the repr was over 14,000 characters (large, but not particularly so for a datastructure). I suspect there is some extra subtlety involved as well, as my real example involved truncating more characters from the front.

In the contrived example, you can increase the 14000 number but it doesn’t seem to change the output.

There should be no such limit. For example, the following code with a thousand times more Os works fine for me:

print("abcdefghijklmnopqrstuvwxyz" + 14_000_000*"O")

What version of macOS are you using and what Mac? Maybe there is a hardware limitation, but I cannot think of anything that would already stop at 14 000.

yeah, your 14 million example works fine for me too. lol. (i mean, it beachballed for a few seconds (2015 Mac Book Pro), but it then printed fine)

But back in 14_000 “O”, i tried taking a screenshot to show that it’s possible i’m not completed deluded, and it appears that the bug may require some amount of printing before the long line.

Notice in my screenshot that i now have none of the “a” to “z” printed. But if i experiment by removing the print statements on lines 3 and 4, then the output is fine.

I forgot to mention that i can cut-and-paste the output and i get the complete output (that is, not truncated at the beginning).

I could hack around the problem.

can you reproduce it or characterise it first? So far it seems that it’s “sometimes output isn’t shown”.

I don’t really know why it happens, but found a way to prevent it.

1 Like

how frustrating!