Search code examples
pythonpython-3.xpython-idle

Any limit to how many characters Python's IDE can take in one line?


I'm a bit curious as I want to create a file containing a dictionary that would automatically update whenever an event occurs and need to know if there is a limit to the number of characters Python's IDE can hold on a single line.

An alternative for me would be at least knowing a way to make the dictionary always start from a new line when it reached a certain length. But I'd still like to know if there is a limit just for knowing's sake.


Solution

  • As far as disk storage and ram memory are concerned, '\n is just another character. As far as tcl/tk and Python's tkinter wrapper are concerned, newlines are very important. Since tk's Text widget is intended to display text to humans, and since vertical scrolling is much more useful for this than horizontal scrolling, it is optimized for the former. A hundred 1000 char lines (100,000 chars total) bogs down vertical scrolling, whereas 300,000 50 char lines (15,000,000 chars total) is no problem. IDLE uses tkinter and the main windows are based on tk's Text widget. So if you to view text in IDLE, keep lines lengths sensible.

    I do not know about other IDEs that use other GUI frameworks. But even if they handle indefinitely long lines better, horizontal scrolling of a 100000 char line is pretty obnoxious.