Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pycharm (a Python IDE) can only show the first 300 members of a list

Tags:

python

pycharm

When I populate a list with more than 300 elements the working environment I'm using to read Python which is Pycharm will only show the first 300 elements. This applies to both the community editions and the professional edition. Does anyone know how to fix this and if not does anyone know of an IDE which can display all the elements of a list, even if that list has 10,000 elements?

Again I want to emphasize that for debugging purposes I need to be able to view the elements of a list.

This shows that more than 300 elements cannot be viewed

This shows the length of the list in question.

like image 266
logic1976 Avatar asked Jan 28 '16 17:01

logic1976


3 Answers

Yes, it's possible to show more items with pycharm.

Look at file helpers/pydev/_pydevd_bundle/pydevd_resolver.py

Edit the MAX_ITEMS_TO_HANDLE to whatever you need.

# Note: 300 is already a lot to see in the outline (after that the user should really use the shell to get things)
# and this also means we'll pass less information to the client side (which makes debugging faster).
MAX_ITEMS_TO_HANDLE = 500

You don't need to restart IDE after the change, just rerun the script.

For Windows 10, the file can be found at Program Files/JetBrains/PyCharm <version>/helpers/pydev/_pydevd_bundle/pydevd_resolver.py

like image 123
Vaclav Kasal Avatar answered Oct 19 '22 01:10

Vaclav Kasal


When I need to inspect long list in debugger I print out the variable with "Evaluate expression" (or alt + F8).

Evaluate expression location

You will get into the command window.

Evaluate expression command window

And then you find your variable in the console window.

Console

like image 13
Petr Javorik Avatar answered Oct 19 '22 03:10

Petr Javorik


you can add one or more watches for the remainder of the list, having a list such as:

my_huge_list = '0' * 1000

then add a watch for my_huge_list[300:] and then my_huge_list[600:] and so on.

It's not super pretty or convenient, but it does work. I'm pretty sure that this can be somehow scripted into pycharm, but my current list has no more than 450 items so this won't be worth it this time.

like image 5
Eric Avatar answered Oct 19 '22 01:10

Eric