Wednesday, May 31, 2023

Re: passing vim9 vars to python3

> Thank you I knew, this is working
>
> vim9script
>
> def g:Py3_SimpleMinimalTest(yml_fpath: string): void
> w:yml_f = yml_fpath
> exe 'py3 print(sys.version)'
> exe 'py3 print(vim.current.window.vars[''yml_f''])'
> enddef
>
> and what about making this works
>
> def g:Py3_SimpleMinimalTest(yml_fpath: string): void
> *var yml_f:string =* yml_fpath
> exe 'py3 print(sys.version)'
> exe 'py3 print(vim.current.*????*.vars[''yml_f''])'
> enddef

Do you mean you want to access variables local to a compiled function by
name? That is not possible. The "l:" namespace that exists in legacy
functions was intentionally left out in compiled functions, because it
adds quite a bit of overhead. You can use a script-local variable to
make this work. It does mean you go outside of the function scope, but
it's still inside the scope of the script file. That means it won't
interfere with what happens in other scripts.

--
From "know your smileys":
<>:-) Bishop

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20230531141312.17DE91C0916%40moolenaar.net.

No comments: