emergent/swarm/evolutionary systems etc

Peter MacKenzie peter9547 at btinternet.com
Fri Apr 2 06:37:49 EST 2004


And how near that future was!  I've been going over the open/read/edit file
stuff again, trying to make it work, but I'm still having no success.  I'm
not sure if I'm missing something fundamental (like a frontal lobe), or if
there's some less worrying problem afoot, but this is what I've been trying.
I've put it through many iterations, dropping and adding brackets and
full-stops, playing around with the structure and grammar etc, but nothing
seems to work.

import sys

file = 'myfile.txt'
open(file,'r+b')
file.write("some string of what you want to write")
file.close()

When I run this, it returns the message:

Traceback (most recent call last):
  File "C:\Python23\openfile.py", line 5, in ?
    file.write()("some string of what you want to write")
AttributeError: 'str' object has no attribute 'write'

It must be something really simple that I've overlooked or failed to grasp,
but I've exhausted my willingness to continue experimenting and attempting
to reverse engineer code from the library modules.  Please help.  My brain
hurts.





More information about the Python-list mailing list