2

When running a Python file from the command line, you use python3 <file>, but VSCode Code Runner uses python3 -u <file> (by default), so I was wondering:

  1. What's the difference (since after testing I see no visible difference)?
  2. What is the -u part called?
Thecave3
  • 762
  • 12
  • 27
ash15khng
  • 191
  • 1
  • 3
  • 11
  • "-u Force stdin, stdout and stderr to be totally unbuffered. On systems where it matters, also put stdin, stdout and stderr in binary mode. Note that there is internal buffering in xread‐ lines(), readlines() and file-object iterators ("for line in sys.stdin") which is not influenced by this option. To work around this, you will want to use "sys.stdin.readline()" inside a "while 1:" loop." – Chris_Rands Jan 23 '19 at 12:39

1 Answers1

5

The -u flag, according to Python's --help statement:

force the binary I/O layers of stdout and stderr to be unbuffered; stdin is always buffered; text I/O layer will be line-buffered; also PYTHONUNBUFFERED=x

This is documented here in the Python docs.

These are known as command line options. There are a number of them, which you can read about using python3 --help.

Jonah Bishop
  • 12,279
  • 6
  • 49
  • 74