jarod_v6--- via Tutor wrote:
> Thanks!!
> I use python2.7 Can Also use in that version?
Yes.
> I don't understand why use partition and not split(). what is the reason
> for that?
If there is exactly one "\t" in the line
key, value = line.split("\t")
and
key, _tab, value = line.partition("\t")
are equivalent, so it's fine to use split(). I used partition() because the
method name indicates that I want two parts, but with the extra assert
parts = line.split("\t")
if len(parts) != 2:
raise ValueError
key, value = parts
would probably have been the better choice because it works the same with
enabled and disabled asserts.
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor