Help writing to file

Discussion in 'Python' started by Stan Cook, Jul 24, 2003.

  1. Stan Cook

    Stan Cook Guest

    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


    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.501 / Virus Database: 299 - Release Date: 7/14/03
    Stan Cook, Jul 24, 2003
    #1
    1. Advertising

  2. Stan Cook

    Ben Finney Guest

    On Thu, 24 Jul 2003 03:33:11 GMT, Stan Cook wrote:
    > 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.

    --
    \ "Demagogue: One who preaches doctrines he knows to be untrue to |
    `\ men he knows to be idiots." -- Henry L. Mencken |
    _o__) |
    http://bignose.squidly.org/ 9CFE12B0 791A4267 887F520C B7AC2E51 BD41714B
    Ben Finney, Jul 24, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kelly

    help writing to a file

    Kelly, Jul 10, 2003, in forum: Perl
    Replies:
    1
    Views:
    1,060
  2. abraham
    Replies:
    0
    Views:
    410
    abraham
    Jul 5, 2003
  3. cur
    Replies:
    1
    Views:
    393
    Daniel Fisher\(lennybacon\)
    Nov 18, 2004
  4. HNguyen
    Replies:
    4
    Views:
    2,398
    HNguyen
    Dec 21, 2004
  5. drew
    Replies:
    6
    Views:
    174
Loading...

Share This Page