<div dir="ltr"><div class="gmail_quote">On Fri, Sep 19, 2008 at 4:49 AM, Paul McGuire <span dir="ltr"><<a href="mailto:ptmcg@austin.rr.com">ptmcg@austin.rr.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="Ih2E3d">because validate, being a transitive verb, tells us we are going to do<br></div>
something to config, but since 'validate' is not a name that clearly asserts<br>
a truth or falsity, we aren't exactly sure what validate is going to return<br>
for valid vs. invalid configs (I could envision a function named 'validate'<br>
could return a list of validation errors, for example). A better name here<br>
is 'is_valid', so that the '== True' can just be dropped, and the code reads<br>
clearly as:<br>
<br>
if config.is_valid():<br>
<br>
</soapbox><br>
-- Paul<br>
<br>
* yes, I know this phrase is itself multiply redundant - sometimes I just<br>
crack myself up.</blockquote><div><br></div><div>Actually, I tend to work this same way myself (though I'm currently taking C++ at school, since they don't offer any serious python classes *tear*) - when I'm sorting an array in C++ (of course in python this is simply a method) I create a boolean value called "sorted" and give it the value False. If you were to translate my code to python it would look a bit like this:</div>
<div><br></div><div>sorted = False</div><div>while not sorted:</div><div> swap values</div><div> if swaps <= 0:</div><div> sorted = True</div><div><br></div><div>Which makes it read a lot more naturally. The same for validating input. In python you could write:</div>
<div><br></div><div>valid_input = False</div><div>while not valid_input:</div><div> my_input = raw_input("Enter something: ")</div><div> if my_input in ('my', 'criteria'):</div><div> valid_input = True</div>
<div><br></div><div>It's worked for me so far ;)</div><div><br></div><div>HTH,</div><div>Wayne</div></div>
</div>