1

If I am using the __ file __ specifier in a Python script that is to be run inside Paraview's built in Python shell it should be able to interpret it correct? or any Python REPL for that matter. But if I were to directly use the __ file __ attribute inside the Python shell then it wouldn't be able to interpret it. Is this correct in thinking?

I am tryin to backtrack an error in Paraview when I try to run a script in the shell that simply tries to recover a file path. This is the script that I am trying to run.

import os
dir = os.path.dirname(os.path.realpath(__file__))
print(dir)

Hopefully this isn't to vague any help would be appreciated I have been stuck on this for a while now.

4
  • Can you post the error traceback? Commented Jan 16, 2020 at 12:22
  • Are you running the above code from a module or REPL? Commented Jan 16, 2020 at 12:26
  • I am running it directly from Paraview's Python REPL. The thing is I don't get any kind of error message I just get an improper file path when it is printed in the REPL. Here is my prior post that nobody responded to that more or less summarizes my issue. Thank you for your response. stackoverflow.com/questions/59752104/… Commented Jan 16, 2020 at 12:29
  • I still have the same issue, see my comment on your solution. Thank you for your help. @AmitTripathi Commented Jan 16, 2020 at 13:21

1 Answer 1

1

Works perfectly in ParaView 5.8-RC1 downloaded from here : https://www.paraview.org/download/

This feature was only added recently, as you can see here : https://gitlab.kitware.com/paraview/paraview/merge_requests/3650

This is only working because ParaView developpers made sure it works. This variable is not automatically available in these kind of environments.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.