__main__ pattern

Report a typo

You have a script with the following code:

current_name = "Steve"

def greet(name):
    print("Hello,", name)

...
    greet(current_name)
    

Replace ... with the line that will make it safe to import this script from another module.

Tip: The devil is in the details! Don't forget about the __, " and :

Enter a short text
___

Create a free account to access the full topic