Reputation: 311
On breakpoints --> PyCharm debugger shows current list of variable states and is also able to show previous lines calculation/call results.
But what if I want to get interim results on function chain calls at the same line of code?
For example:
l = [3, 4, 5]
l = list(map(str, l)) #here I want to check result "of map(str, l)"
s = "_".join(l).upper()[::-1] #here I want see values for each interim func calls (join, upper)
Is it somehow possible in PyCharm?
Upvotes: 2
Views: 214
Reputation: 12910
This can be done by using a breakpoint on that line. Right click on the breakpoint and use a tuple in the Evalute and log
field having as values the incremental method chain calls:
The following code shows differences in intermediate results:
l = ['Hello', 'my', 'friends']
s = "_".join(l).upper()[::-1]
Using a tuple in Evaluate and log
:
(l, "_".join(l), "_".join(l).upper(), "_".join(l).upper()[::-1])
The debugger shows the results on standard output:
(['Hello', 'my', 'friends'], 'Hello_my_friends', 'HELLO_MY_FRIENDS', 'SDNEIRF_YM_OLLEH')
Corresponding screenshot:
Upvotes: 1