huh? Python says that AttributeError: 'string' object has no attribute 'split'

David Fisher python at rose164.wuh.wustl.edu
Wed Apr 26 13:46:17 CEST 2000


----- Original Message -----
From: <schmitthead at my-deja.com>
Newsgroups: comp.lang.python
To: <python-list at python.org>
Sent: Wednesday, April 26, 2000 1:37 AM
Subject: huh? Python says that AttributeError: 'string' object has no
attribute 'split'

>
> #mac2dos.py-------------------------------------------------------------
> import os
> import sys
> import string
>
>
> #-----------------------------------------------------------------------
> def mac2dosfile( file ):
>  myline = file.read()
>  lines = myline.split( myline, chr(10) )

change to:

lines = string.split( myline, chr(10) )
           ^^^^^

>  for l in lines:
>   l = l.strip( l )
>  file.writelines( lines )
>
> #-----------------------------------------------------------------------
> def callbackfunc( junk, dir, names ):
>  for name in names:
>   file = open( name, 'r+' )
>   mac2dosfile( file )
>   close( file )
>
>
> #-----------------------------------------------------------------------
> def mac2dos( dir ):
>  os.path.walk( os.getcwd(), callbackfunc, '' )
>
>
> #-----------------------------------------------------------------------
> if __name__ == '__main__':
>  if ( len(sys.argv) < 2 ):
>   directory = os.getcwd()
>  else:
>   directory = sys.argv[1]
>  mac2dos( directory )
> #-end-of-mac2dos.py-----------------------------------------------------
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
> --
> http://www.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list