Describe the problem/error/question
In the older versions of n8n, on Python code nodes, I could access the output of a previous node using this kind of code:
prev_node_data = _items(‘prev_node’)[0][“json”][“some_key”]
The problem is in the newest version of n8n, with the Python (Native) (Beta), where the underscore “_” is not supported:
The native Python option does not support _ syntax and helpers, except for _items in all-items mode and _item in per-item mode
So I need to change my codes, but IDK how.
Any information available about this?
What is the error message (if any)?
‘list’ object is not callable
Please share your workflow
This is an example node that used to work before, but now it gives me the error message.
Share the output returned by the last node
Information on your n8n setup
- n8n version: 1.115.3
- Database (default: SQLite): default
- n8n EXECUTIONS_PROCESS setting (default: own, main): default
- Running n8n via (Docker, npm, n8n cloud, desktop app): cloud
- Operating system: windows
To add a little bit of information:
In the previous version, if I needed to access the output of a previous node, I just replace the “$” symbol from the JavaScript syntaxis with the underscore for Python. Now, with the deprecation of the underscore, that’s impossible.
Second this. I’m experiencing the same problem. I can’t figure out how to reference the output of previous nodes. whats described in the documentation is out of date and doesn’t work.
I’m impressed that nobody else is working about this issue.
One way in using to solve it, in my local version, is to use an old version of n8n, without the Python Native option.
Anyway, I hope they update the doc about python nodes.
Quite late reply, for those you will land on this question: check out this answer Changes to python code node in v1.120+ - #2 by mohamed3nan
tldr, new Python (Native) interpreter do not support “_“ syntax, except “_items“ and “_item“
If you want to retrieve data from previous node
simply do
- _item[“json”] for
Run once for each item mode
- items[0][“json”] for
Run once for all items mode
but I also facing this issue as well, I want to retrieve the data from 4 back nodes not the previous one.