Friday, February 10, 2023

Re: Passing python3 file arguments seems failing py3f

> Following vim's python help,
>
>
> *"To pass arguments you need to set sys.argv[] explicitly. Example: > *
> :python sys.argv = ["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"]
>
> Is it due to python3 file?

It works for me. Typing these commands in sequence:

py3 sys.argv = ["argument"]
py3file /tmp/test.py

With /tmp/test.py:

print("testing pyfile")
print(sys.argv)
print("testing end")

Output:

testing pyfile
['argument']
testing end

This is on Ubuntu, Python 3.10.


--
hundred-and-one symptoms of being an internet addict:
107. When using your phone you forget that you don't have to use your
keyboard.

/// 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/20230210145102.C532B1C247D%40moolenaar.net.

No comments: