Re: [Tutor] function with multiple checks

2010-09-27 Thread Tim Miller
On 28/09/10 01:50, Brian Jones wrote: On Mon, Sep 27, 2010 at 11:43 AM, Brian Jones mailto:bkjo...@gmail.com>> wrote: How about this: d = [digits, punctuation, ascii_uppercase, ascii_lowercase] s = 'asdf1234A' for c in d: if not [x for x in s if x in c]: print x, ' not in ', c Ju

Re: [Tutor] function with multiple checks

2010-09-27 Thread Tim Miller
On 28/09/10 01:46, Jerry Hill wrote: The way you've written it obviously works fine. That being said, I'd probably do something like this: from string import ascii_lowercase, ascii_uppercase, digits, punctuation def complex_password(password): '''Checks to make sure a password is complex'

Re: [Tutor] function with multiple checks

2010-09-27 Thread Tim Miller
set does seem to have what you want: isdisjoint() could do the trick. Eg: if set(punctuation).isdisjoint(password) or set(digits).isdisjoint(password) or set(ascii_uppercase).isdisjoint(password) or set(ascii_lowercase).isdisjoint(password): return False return True You co

[Tutor] function with multiple checks

2010-09-27 Thread Tim Miller
I've got a small function that I'm using to check whether a password is of a certain length and contains mixed case, numbers and punctuation. Originally I was using multiple "if re.search" for the patterns but it looked terrible so I've read up on list comprehensions and it's slightly improved