Because of import rules in Python 3, a module that imports other modules
cannot be run with
:!python filename.
In a directory that looks like this:
ProjectFolder
main.py
PackageFolder
module.py
I can run main.py from ProjectFolder with>
:!python main.py
But I cannot run module.py from PackageFolder with
:!python module.py
I've got to run module.py from ProjectFolder with
:!python -m PackageFolder.module
Is there a way to automote this in vim?
Or, more complex, to create:
if file in working directory:
:!python %
else:
:!python -m filedir.filename
Or, even more complex:
else:
:!python -m path.from.workingdir.to.filedir.filename
I have a key bound to :!python %
A second key-binding for the other form would be enough to serve my needs.
If/then would of course be even better, but I cannot begin to figure this
out by myself.
--
View this message in context: http://vim.1045645.n5.nabble.com/trying-for-python-m-packagedir-modulename-tp5711521.html
Sent from the Vim - General mailing list archive at Nabble.com.
--
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
No comments:
Post a Comment