hI, I know nothing about Python but it's on my computer. When I try to open a file, it pops up and closes immediately. How do I change that?
opening a file
Collapse
X
-
Originally posted by pjpcolohI, I know nothing about Python but it's on my computer. When I try to open a file, it pops up and closes immediately. How do I change that? -
What operating system?
How are you interacting with python, do you just type "python" to start the interpreter, or are you working within an IDE like Idle, or pythonwin?
In general though, when you open a file, you are just creating an instance of an open "file object" (see docs), or example
Code:>>> f=open('/tmp/tmp.txt','r') >>> print f <open file '/tmp/tmp.txt', mode 'r' at 0x008E72A8>
Comment
Comment