you forgot to import sys
sys is the "System-specific parameters and functions" module of python - python docs.
what this does is get the system specific standard out pipe for the python file to output to. as in a stream it can write to :).
File and sys.stdout
, sys.stdin
and sys.stderr
are all just streams to write to.
In general if it says NameError
you either forgot to import something or you didn't define something correctly :)
you probably want to rewrite that as opened_file or the like, File
and some other words similar like if you did random = 3
are never good to address because they are used as names of various Python objects or internals - and you want to make sure you don't have collisions even though Python is supposed to resolve these cleverly :)