Keywordargument in string.split
P.J.W.S. Vrijlandt
P.J.W.S.VRIJLANDT at INT.azg.nl
Thu Jan 27 05:38:42 EST 2000
I wrote:
> I have this error I don't quite understand.
> Why can't I give 'sep' as a keyword argument?
>
> It seems that the string module I import, is not the string.py in the
> standard distribution but a not-quite-equivalent c-implementation of
> it.
I got replies pointing to 'strop', which is a c-implementation of
string, and is imported by string.py
But what is the header (def) of split in strop?
(and why is it different)
>
> Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on
> win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> >>> import string
> >>> string.split('abcd', sep = 'c')
> Traceback (innermost last):
> File "<pyshell#1>", line 1, in ?
> string.split('abcd', sep = 'c')
> TypeError: this function takes no keyword arguments
> >>> def split(s, sep=None, maxsplit=0): # = string.split
> print s, sep,
> maxsplit >>> split('abcd', sep = 'c')
> abcd c 0
>
> --
> http://www.python.org/mailman/listinfo/python-list
>
Met vriendelijke groet,
Patrick Vrijlandt
More information about the Python-list
mailing list