I prefer my option over your is_permutation_of :
def is_perm(a,b): return sorted(str(a)) == sorted(str(b))
And I think this is better for has_even_digit
def has_even_digit(n): evens=set(['0', '2', '4', '6', '8']) return any(c in evens for c in str(n))
Or even use a tuple rather than a set:
def has_even_digit(n): return any(c in ('0', '2', '4', '6', '8') for c in str(n))
Edit
From the comment stream, I think you're looking for something like this:
This does not work because integers do not support iteration in Python. Also, there is no real need to have something like a whole iteration, since it is so idiomatic and easy to use with strings.
Here is the Python framework that does this with strings, but produces a single integer digit:
for d in [int(c) for c in str(123456)]:
If you need the same number from right to left:
for d in [int(c) for c in str(123456)[::-1]]: # Now right (least significant digit) to left (most significant digit)
Compare these two simple cases by doing them with actual math with integer or long:
def int_iter(n,reverse=False): rtr=[] if not isinstance(n, (int,long)): raise ValueError('n must be int or long') while n: rtr.append(n%10) n/=10 if reverse: return rtr[::-1] else: return rtr
Actually it is much easier to use strings and probably faster. If you need high speed, do it in C.