Powershell equivilent of python's if __name__ == '__main__':

Posted by Mark Mascolino on Stack Overflow See other posts from Stack Overflow or by Mark Mascolino
Published on 2011-01-14T17:24:12Z Indexed on 2011/01/14 17:53 UTC
Read the original article Hit count: 237

Filed under:

I am really fond of python's capability to do things like this:

if __name__ == '__main__':
    #setup testing code here
    #or setup a call a function with parameters and human format the output
    #etc...

This is nice because I can treat a Python script file as something that can be called from the command line but it remains available for me to import its functions and classes into a separate python script file easily without triggering the default "run from the command line behavior".

Does Powershell have a similar facility that I could exploit? And if it doesn't how should I be organizing my library of function files so that i can easily execute some of them while I am developing them?

© Stack Overflow or respective owner

Related posts about powershell