Where's split gone?

Remco Gerlich scarblac at pino.selwerd.nl
Thu Oct 5 05:26:15 EDT 2000


Dale Strickland-Clark <dale at out-think.NOSPAMco.uk> wrote in comp.lang.python:
> The scene: Win32 (Win98 or Win2000), Python 1.6, IIS or PWS
> 
> I have a COM object written in Python. If I call it from VBScript or
> JScript in Windows, it works.
> 
> However, if I call it from an ASP script running under PWS or IIS - on
> the same machine, it fails with the following:
> 
> Python COM Server Internal Error error '80004005' 
> Unexpected Python Error: exceptions.AttributeError: split 
> 
> The only 'split' in the source is a call to the on in the string
> module - yet a little earlier in the same code, I call string.join
> without grief.
> 
> What might be the problem here?

In 1.6, join and split are string methods. The versions in the string
module just call the string method like:

def split(s, sep=" "):
   return s.split(sep)
   
def join(l, sep=" "):
   return sep.join(l)

(see the library source)

Now if your string isn't a real string but some string-like object, it might
not have the .split() method, and therefore string.split will fail, with
that AttributeError.
string.join, on the other hand, calls the method on the separator, and that
is a string.

Is my guess.

-- 
Remco Gerlich



More information about the Python-list mailing list