Re: [Tutor] Forgot something...

2008-01-25 Thread Kent Johnson
Timothy Sikes wrote:
> Sorry, but in my previous message, I realized that I hadn't changed the 
> code from doesNotHave...  It's supposed to be x.find(), not 
> x.startswith..

You meant to write:

def doesNotHave(exclude, root):
 for x in exclude:
 if root.find(x) > -1:
 return False
 return True

This can be written as
def doesNotHave(exclude, root):
 for x in exclude:
 if x in root:
 return False
 return True

or

def doesNotHave(exclude, root):
 return not any(x in root for x in exclude)

Kent
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Forgot something...

2008-01-24 Thread Timothy Sikes
Sorry, but in my previous message, I realized that I hadn't changed the code 
from doesNotHave...  It's supposed to be x.find(), not x.startswith..Oh, 
and I also am not worried about messing up any files too much, because I have 
them all backed up on another computer already
_
Helping your favorite cause is as easy as instant messaging. You IM, we give.
http://im.live.com/Messenger/IM/Home/?source=text_hotmail_join___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor