Why this Error may happend? I have to readjust huge application and I need the most supposed possibilities which make this kind of error.

You are trying to use string as file. If that is your purpose use the cStringIO module.

>>> x = 'car'
>>> x.close()
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
AttributeError: 'str' object has no attribute 'close'

As tony mention str has no close() method as a file object.

cStringIO module has close(),or maybe you are trying to use close on what you think is a file object.
You can check type like this.

>>> x = 'car'
>>> type(x)
<type 'str'>
>>>
#cStringIO demo
>>> from cStringIO import StringIO
>>> output = StringIO()
>>> output.write('This goes into the buffer.\n')
>>> output.write('car')
>>> print output.getvalue()
This goes into the buffer.
car
>>> output.close() # discard buffer memory

thanks for your respondings. I solved my problem with your big help ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.