+ 1
In what variable is the output of print() stored?
consider the code: x=8 print(x+10) obviously, we get a result 18. Since i haven't assigned it to anything, Where is this integer 18 stored?
4 Answers
+ 4
Stored in this file:
sys.stdout
To access do:
import sys
to write stuff to it,
sys.stdout.write("Str")
#same as print("Str")
+ 1
Pretty sure it'd be stored in memory. Because print() does the calculations and stuff.
+ 1
@Pegasus
True, it is stored in sys.stdout. Also, you can just use the file argument of the print builtin to print to the 3 system file streams:
import sys
print("stderr!", file=sys.stderr)
- 1
I know it's stored in memory!
I want to know where is it stored. Is there a way I can access it later?