Function to retrieve running script

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Harlin Seritt

    #1

    Function to retrieve running script

    Is there a function that allows one to get the name of the same script
    running returned as a string?

    Thanks,

    Harlin Seritt

  • Alex Martelli

    #2
    Re: Function to retrieve running script

    Harlin Seritt <harlinseritt@y ahoo.com> wrote:
    [color=blue]
    > Is there a function that allows one to get the name of the same script
    > running returned as a string?[/color]

    Something like:

    import sys
    def f():
    return sys.modules['__main__'].__file__

    might help.


    Alex

    Comment

    • Mike Meyer

      #3
      Re: Function to retrieve running script

      "Harlin Seritt" <harlinseritt@y ahoo.com> writes:[color=blue]
      > Is there a function that allows one to get the name of the same script
      > running returned as a string?[/color]

      The questions a little ambiguous, but one answer might be:

      import sys
      myname = sys.argv[0]

      <mike

      --
      Mike Meyer <mwm@mired.or g> http://www.mired.org/home/mwm/
      Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

      Comment

      • Harlin Seritt

        #4
        Re: Function to retrieve running script

        Thanks Mike,

        that will work just as well... just disappointed in myself that i lack
        the creativity to think of something that simple ;-)

        thanks,

        Harlin

        Comment

        Working...