-2

I saw someone on a Python post refer to it in some way, but I cannot for the life of me find it again. It was a pretty short, colloquial term, something like "gutter" or "blunk".

Is it a Python thing or do other languages call it something too?

wovano
  • 4,543
  • 5
  • 22
  • 49
  • 3
    I've seen somewhere was called `guard statement`, though `"conditional script" stanza` sounds more fancy. I'm looking forward to see if you find your answer to this. – FAB Nov 24 '22 at 09:58
  • How about 'Name-Main Idiom'? – Eljas Hyyrynen Nov 24 '22 at 10:18
  • 1
    [This answer](https://stackoverflow.com/a/419185/6045800) suggests "name/`__name__` guard". I would add to the pool "main guard" – Tomerikoo Nov 24 '22 at 10:32
  • Yes! I think it was 'main guard' or 'guard statement'! Thanks! I'm new to (posting on) SO, I can't mark one of your comments as answer, can I? Is it etiquette to have a marked answer? – linkcharger Nov 25 '22 at 11:10
  • 2
    linkcharger, see [What should I do when someone answers my question?](https://stackoverflow.com/help/someone-answers) (and you can't "accept" a comment, comments are not meant to give answers) – wovano Nov 25 '22 at 11:12
  • @Tomerikoo, maybe you can post your comment as an answer. – wovano Nov 25 '22 at 11:14

1 Answers1

2

In the documentation up to Python 3.3 it's referred to as a "conditional script" stanza:

It is this environment in which the idiomatic “conditional script” stanza causes a script to run:

if __name__ == "__main__":
    main()

This term is gone since 3.4:

a common idiom for conditionally executing code in a module when it is run as a script or with python -m but not when it is imported:

if __name__ == "__main__":
    # execute only if run as a script
    main()
Thomas
  • 174,939
  • 50
  • 355
  • 478
  • Nice catch! Though the term I saw was much more colloquial.. like it would appear in Urban Dictionary for code, like people actually use it in daily speech – linkcharger Nov 24 '22 at 09:51