patch 9.1.0844: if_python: no way to pass local vars to python
Problem: if_python: no way to pass local vars to python
Solution: Add locals argument to py3eval(), pyeval() and pyxeval()
(Ben Jackson)
fixes: #8573
closes: #10594
Signed-off-by: Ben Jackson <puremourning@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
fd1a838d36
commit
ea19e7856b
@ -1,4 +1,4 @@
|
||||
*if_pyth.txt* For Vim version 9.1. Last change: 2024 May 16
|
||||
*if_pyth.txt* For Vim version 9.1. Last change: 2024 Nov 06
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Paul Moore
|
||||
@ -201,6 +201,10 @@ vim.eval(str) *python-eval*
|
||||
[{'cmd': '/^eval_expr(arg, nextcmd)$/', 'static': 0, 'name': ~
|
||||
'eval_expr', 'kind': 'f', 'filename': './src/eval.c'}] ~
|
||||
|
||||
NOTE: In vim9script, local variables in def functions are not visible
|
||||
to to python evaluations. To pass local variables to python evaluations,
|
||||
use the {locals} dict when calling |py3eval()| and friends.
|
||||
|
||||
vim.bindeval(str) *python-bindeval*
|
||||
Like |python-eval|, but returns special objects described in
|
||||
|python-bindeval-objects|. These python objects let you modify (|List|
|
||||
@ -741,6 +745,10 @@ To facilitate bi-directional interface, you can use |pyeval()| and |py3eval()|
|
||||
functions to evaluate Python expressions and pass their values to Vim script.
|
||||
|pyxeval()| is also available.
|
||||
|
||||
You can inject local variables into the evaluation using the optional {locals}
|
||||
dict. This can be particularly useful in vim9script where vim.eval
|
||||
|python-eval| will not find locals in a def func.
|
||||
|
||||
The Python value "None" is converted to v:none.
|
||||
|
||||
==============================================================================
|
||||
|
||||
Reference in New Issue
Block a user