22

I'm debugging Python code and when I try to show the contents of an string variable its showed truncated...

How can show the full contents of a variable debugging Python code with PyDev on Eclipse?

1
  • Unfortunately as this is a Python specific answer---If you are trying to view a certain section of the string you could always use some_string[x:y] to select from the xth to the yth element to view that in the expression tab of the debug environment. Commented Feb 10, 2014 at 3:26

4 Answers 4

44

If you right-click on the details pane in either the "Variables" view or the "Expressions" view, there is a Max Length... menu option. You can enter a number there to configure the truncation of string output. Keep in mind that the calculated length includes the type identifier at the beginning, so str: 12345 is actually 10 characters, not 5.

There seems to be a hard limit of 1000 characters, even when entering 0, which the field description claims means "unlimited," so no matter what you put in, you will never see more than 1000 characters. I don't know if that's a known issue or not; I have not looked into it. For strings or other variables longer than this, I generally use the logging module from the standard library and send the string to a log file or stderr.

Sign up to request clarification or add additional context in comments.

5 Comments

I need more than 1000 characters to view because I want to view an XML web response. About using logging its a nice way when debugging your own code but in my case I'm debugging thirty-party libraries to see what is happening and to use logging is annoying.
Note: the "details pane" is the blank space where the strings are displayed. Maybe obvious for the most...
it's actually 1024 characters
For me there is no limit. The Max Value was by default set to 10.000, I set it to 0 (unlimited) and my 25.000 chars string is displaying completely.
@UmbySlipKnot found a way to OVERCOME THE 1024 character limit! In the Variables view you right-click on the variable and select Change value.
5

Use interactive commands for printing your big variables and don't rely on variables view. Check how to do it at aptana pydev debug console.

Comments

4

Found the way around!

At the breakpoint start PyDev Debug Console enter image description here enter image description here

and then use python interpreter to get the value

Comments

1

As this was the top hit on Google I should add that if you right-click on the variables pane in debug mode and select 'copy variables' the string value that Eclipse is truncating (along with all other variables) is added in full to the system clipboard.

you can then paste it into your favourite text editor to extract the targeted value

2 Comments

That doesn't seem to be true at least for Eclipse 4.2.1 on Ubuntu. When I right click and "Copy Variable" I still get the truncated output on my clipboard.
This does work for me (Luna / 4.4.1 on Windows 7). Note that it copies the variable type and name along with the value.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.