[Pythonmac-SIG] MacPython OSX beginner concepts ~/Desktop

Bob Ippolito bob at redivi.com
Tue Jan 11 02:00:31 CET 2005


On Jan 10, 2005, at 17:13, AdvertisingDept wrote:

> In apple's terminal app I can type:
>
> touch ~/Desktop/foobar
>
> and create an empty file.
>
>
> How do I go about doing this in Apple's Python2.3 Panther?

import os
foobarPath = os.path.expanduser('~/Desktop/foobar')
foobarFile = open(foobarPath, 'w')
# ... write something to foobarFile
foobarFile.close()

-bob



More information about the Pythonmac-SIG mailing list