[Tutor] Flow control question.
A.M. Kuchling
amk at asti-usa.com
Mon Aug 11 15:17:35 EDT 2003
On Mon, Aug 11, 2003 at 11:19:26AM -0400, Clay Shirky wrote:
> for new_address in new_addresses:
> if new_address == 0: continue # I want to skip the next test
> if test_mac(new_address) == test_mac(orig_address):
> print new_address, "matches", orig_address
> else:
> print new_address, "doesn't match..."
I'm a bit confused; is some code not included in your post that sets
elements of the new_addresses list to 0? It looks to me like
new_address is some string 'aa:bb:cc:...' and you want to continue if
test_mac() returns 0, so the loop would be:
for new_address in new_addresses:
result = test_mac(new_address)
if new_address == 0:
continue # I want to skip the next test
if result == test_mac(orig_address):
print new_address, "matches", orig_address
else:
print new_address, "doesn't match..."
If your original code is what you want, then perhaps the problem is
that new_address is being set to the string '0'; '0' looks just
like the number 0 if you print it, but won't compare as equal. Try printing
repr(new_address), or type(new_address), to check this.
--amk (www.amk.ca)
RICHARD: Deep malice makes too deep incision.
-- _Richard II_, I, i
More information about the Tutor
mailing list