Name of julia source file?

How can I obtain the name of the current (or main/top) julia source file, from within the code?

Base.source_path()

1 Like

I’m not sure if you are asking about the source code of functions, but if that’s the case, you can find the path of all the methods of any function f with methods(f)

There are also @__FILE__ and PROGRAM_FILE:

help?>  @__FILE__
  @__FILE__ -> AbstractString

  Expand to a string with the path to the file containing the macrocall, or
  an empty string if evaluated by julia -e <expr>. Return nothing if the
  macro was missing parser source information.
  Alternatively see PROGRAM_FILE.
help?> PROGRAM_FILE
search: PROGRAM_FILE

  PROGRAM_FILE

  A string containing the script name passed to Julia from the command
  line. Note that the script name remains unchanged from within included
  files. Alternatively see @__FILE__.
3 Likes