From 4808a68f7d0e009e96aef59ee0ec748aa3fc4318 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Thu, 17 Feb 2005 23:30:54 +0000 Subject: [PATCH] Added utils.iter.startswith. --- src/utils/iter.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/utils/iter.py b/src/utils/iter.py index 419504371..5e47c91c0 100644 --- a/src/utils/iter.py +++ b/src/utils/iter.py @@ -148,4 +148,14 @@ def ilen(iterable): i += 1 return i +def startswith(long, short): + longI = iter(long) + shortI = iter(short) + try: + while True: + if shortI.next() != longI.next(): + return False + except StopIteration: + return True + # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: