nbro
nbro

Reputation: 15868

Is there the redirect operator >> in Python 3?

I did not know there was a redirect operator in Python 2, for example here somebody is using it to redirect something to a file. I just knew that there is one in Bash. Is still there such a thing in Python 3?

Upvotes: 1

Views: 1238

Answers (2)

falsetru
falsetru

Reputation: 369364

print function in Python 3.x optionally accept file parameter, you can specify file object.

import sys

print(n, file=sys.stderr)

Upvotes: 3

Zhormos
Zhormos

Reputation: 31

Using the shell redirection this way

python foo_bar.py > file

is still possible with python 3.x as this is not a feature of python itself but this is actually a feature of the shell interpreter in which the python command is run.

Upvotes: 0

Related Questions