Keywordargument in string.split
P.J.W.S. Vrijlandt
P.J.W.S.VRIJLANDT at INT.azg.nl
Wed Jan 26 11:46:40 EST 2000
Hi all,
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.
Patrick
----------------------
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
More information about the Python-list
mailing list