Re: Difficulty with maxsplit default value for str.split

2006-09-25 Thread Steven D'Aprano
On Sun, 24 Sep 2006 10:34:31 +0200, Fredrik Lundh wrote: >> But the split method doesn't accept a value of None for maxsplit, and I >> don't know what default value I should be using. > > def mysplit(S, *args): > pre_processing() > result = S.split(*args) > post_processing(

Re: Difficulty with maxsplit default value for str.split

2006-09-25 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes: > Is it safe for me to pass -1 as the default to maxsplit, meaning > "unlimited splits"? Should the docs be fixed to mention that? Frederik gave a simple and practical solution to your immediate problem, but yes, I think the docs should be fixed after ch

Re: Difficulty with maxsplit default value for str.split

2006-09-24 Thread Fredrik Lundh
Steven D'Aprano wrote: > I'm having problems passing a default value to the maxsplit argument of > str.split. I'm trying to write a function which acts as a wrapper to > split, something like this: > > def mysplit(S, sep=None, maxsplit=None): > pre_processing() > result = S.split(sep, max

Re: Difficulty with maxsplit default value for str.split

2006-09-23 Thread Nick Vatamaniuc
Steven, According to the current Python source the default value of maxsplit=-1. I think you can count on that as I don't think there would be a reason to change it in the future. If you are really worried about it then your version of calling a particular version of split should work. By the way