Friday, February 10, 2023

Re: Passing python3 file arguments seems failing py3f

On Thu, Feb 09, 2023 at 11:50:19AM -0800, N i c o l a s wrote:
> Following vim's python help, 
>
> "To pass arguments you need to set sys.argv[] explicitly.  Example: >
>
>     :python sys.argv = ["foo", "bar"]
>     :pyfile myscript.py
> "

That is not a very good example, since sys.argv[0] contains the name of
the script. It would be less confusing if the example said

:python sys.argv = ["myscript.py", "foo", "bar"]
:pyfile myscript.py

> I tried to pass argues to python file as this 
>
> export def PyLinter(): void
>   py3 import sys
>   py3 sys.argv = ["--version"]
>   exe 'py3f ' .. "path/to/somepythonfile.py"
> enddef
>
> It's like as if it had no effect :   py3 sys.argv = ["--version"]

Try

py3 sys.argv = ["somepythonfile.py", "--version"]

Marius Gedminas
--
We have enough youth, how about a fountain of SMART?

--
--
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/20230210090139.7m5eo2zku5ynnllo%40blynas.

No comments: