3

this might be a pure python problem or a problem with arcpy. please help me out:

    min_area = float(GKPROZ_functions.min_of_field(out_name,"Shape_Area"))
    print area_max
    if min_area > area_max:
        print "success!"
    else:
        print "failed."            

    if min_area > 100:
        print "success!"
    else:
        print "failed."

    print str(min_area)

output:

100
failed.
success!
100.018289077

min_of_field returns the minimum value of the field "Shape_Area" of the whole feature class. it is (apparently) 100.018289077. however if i check that with area_max (supposedly 100) it says it's smaller (failed!). if i check it with 100, it says it's bigger(success!). what mistake am i making here? thanks in advance.

1 Answer 1

3

The code you have provided does not show how area_max is assigned a value. When I ran your code, assigning area_min = float(100.0182890771) and area_max = float(100) I get a correct output:

success!
success!
100.018289077

However, If I assign area_max = str(100) I am able to replicate the error:

failed.
success!
100.018289077

It could be that your error is in the assignment of the area_min value but its hard to say for sure without that part of the code.

2
  • this was indeed the problem. i am still unexperienced with python and the ambiguity of types tricked me into thinking everything was ok. thank you for your time! Commented Aug 31, 2012 at 11:01
  • You're welcome. It can be tricky to begin with, but you'll soon learn to check for these things.
    – sgrieve
    Commented Aug 31, 2012 at 11:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.