Recurring patterns: Am I missing it, or can we get these added to the language?
robin at nibor.org
Tue Apr 15 21:35:45 CEST 2008
> This is like split() but returns a list of exactly lenght n. This is
> very useful when using unpacking, e.g.:
> x, y = nsplit('foo,bar,baz', ',', 2)
You could use the second argument of split:
x, y = 'foo,bar,baz'.split(',', 1)
Note that the number has the meaning "only split n times" as opposed to
"split into n parts".
More information about the Python-list