I just started learning Python about a week ago. I've made considerable progress thanks to everyone who has asked and answered questions. I came across a problem last night and after a lot of searching and pondering-- I still can't figure it out.
I tried making a Python project in xcode but I can't find the output file. I started the project by selecting "Cocoa-Python Application from the "Choose your template menu:" In the main.py file, I have the following code:
import objc
import Foundation
import AppKit
from PyObjCTools import AppHelper
file = open('test.txt', 'w')
print >> file, 'Test of the emergency broadcast system.'
print 'This is merely a test...'
file.close()
The console shows the "This is merely a test..." statement but I can't find the output file 'test.txt' anywhere. I've searched the computer and it's nowhere to be found. I'm sure it's something silly, but what am I missing?
Print this to your console, and you'll see the file name:
print file
http://docs.python.org/tutorial/inputoutput.html#reading-and-writing-files
If that just shows you the relative path, print the cwd like so:
from os import getcwd
print 'Current directory:', getcwd()