Help writing to file

S

Stan Cook

I'm trying to have my program write to a log file. I have the idea, but I'm
getting an error and don't understand why.

File "D:\AetInstall\aet.py", line 201, in load_progs
_log.write(string.ljust( _serv, 25))
AttributeError: 'str' object has no attribute 'write'

I get the above message from this section of code:

for s in _image:
_serv = s
print _serv
_ErrorLevel=map_server(_serv)
_log.write(string.ljust( _serv, 25))

_image is a list containing server names.

Any help would be appreciated.

Thanks,

Stan
 
B

Ben Finney

I'm trying to have my program write to a log file. I have the idea,
but I'm getting an error and don't understand why.

File "D:\AetInstall\aet.py", line 201, in load_progs
_log.write(string.ljust( _serv, 25))
AttributeError: 'str' object has no attribute 'write'

Seems fairly self-explanatory. You're invoking the 'write' attribute on
an object of type 'str', which has no such attribute.

Likely you've unintentionally assigned a string value to _log at some
point earlier in the code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top