import vs include [message #1835707] |
Thu, 10 December 2020 18:49 |
Axel RICHARD Messages: 43 Registered: September 2010 Location: France |
Member |
|
|
Hello,
I do some tests with EASE and PyDev and its really powerful! Kudos to the team!
Let's say I have two Python scripts in the same folder.
AddReadMe.py
loadModule('/System/Resources')
def fct_readme():
for iproject in getWorkspace().getProjects():
if not iproject.isOpen():
continue
ifile = iproject.getFile("README.md")
if not ifile.exists():
contents = "# " + iproject.getName() + "\n\n"
if iproject.hasNature("org.eclipse.jdt.core.javanature"):
contents += "A Java Project\n"
elif iproject.hasNature("org.python.pydev.pythonNature"):
contents += "A Python Project\n"
writeFile(ifile, contents)
and Test.py. In Test.py I want to call fct_readme().
The first approach:
import scripts.AddReadMe
scripts.AddReadMe.fct_readme()
leads to an error when executed with Run As > EASE Script (ImportError: No module named scripts.AddReadMe)
The second approach:
include('script://AddReadMe.py')
fct_readme()
is well executed with Run As > EASE Script.
The problem with the second approach is that PyDev shows errors for the include(...) statement and the fct_readme() call.
Is it possible to have no editor error with PyDev editor with the second approach, or better have no execution error with the first approach?
Any pointers to solve one or both problems will be appreciated.
Thank you,
Axel Richard
Obeo
[Updated on: Thu, 10 December 2020 18:50] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03475 seconds