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.

Din Djarin
  • 13
  • 5
  • Can you post the error traceback? – Amit Tripathi Jan 16 '20 at 12:22
  • Are you running the above code from a module or REPL? – Amit Tripathi Jan 16 '20 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. https://stackoverflow.com/questions/59752104/paraviews-python-shell-not-reading-file-path-corectly – Din Djarin Jan 16 '20 at 12:29
  • I still have the same issue, see my comment on your solution. Thank you for your help. @AmitTripathi – Din Djarin Jan 16 '20 at 13:21

1 Answers1

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.

Mathieu Westphal
  • 2,544
  • 1
  • 19
  • 33