opening file: Writing is invalid mode

876 Views Asked by At

When executing:

path=os.path.dirname(__file__)+'/log.txt'
log=open(path,"w",encoding='utf-8')

I get:

log=open(path,'w',encoding='utf-8')
File "C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 1203, in __init__
raise IOError('invalid mode: %s' % mode)
IOError: invalid mode: w

I'm not sure why I can't write to the file?

2

There are 2 best solutions below

0
On BEST ANSWER

App Engine's Python runtime supports Python 2.5 – newer versions of Python, including Python 2.6, are not currently supported. For security reasons, some Python modules written in C won't run in App Engine's sandbox. Because App Engine doesn't support writing to disk or opening direct network connections, other libraries that rely on this may not be fully usable.

0
On

You can't write to disk in App Engine. At all. You must use datastore.