<br><br><div class="gmail_quote">On Wed, Jul 21, 2010 at 12:02 PM, Jack Diederich <span dir="ltr"><<a href="mailto:jackdied@gmail.com">jackdied@gmail.com</a>></span> wrote:</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<snip> </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">2a) No control flow statements in the block means if you need to<br>
augment the code to do a return/break/continue/yield you then have to<br>
refactor so everything in the "given:" block gets moved to the top and<br>
a 1-line change becomes a 10 line diff.<br>
2b) Allowing control flow statements in the block would be even more confusing.<br>
2c) Is this legal?<br>
     x = b given:<br>
       b = 0<br>
       for item in range(100):<br>
         b += item<br>
         if b > 10:<br>
           break</blockquote></div><br><div>2a) you are missing the point of the given clause. you use it to assign values to variables if, and only if, the only possible results of the computation are </div><div>1) an exception is raised or</div>

<div>2) a value is returned which is set to the variable and used in the expression no matter its value.</div><div>if there is the slightest chance that what you describe might be necessary you would not put it in a "given" but do something like this: (assumes that a given is applied to the previous statement in its current block)</div>

<div><br></div><div>if some_bool_func(a):</div><div>    ans = some_func1(a, b, c)</div><div>else:</div><div>    ans = some_func2(a, b, c)</div><div>given: # note: given applied to the block starting with the "if" statement</div>

<div>    a = get_a()</div><div>    b = get_b()</div><div>    c = get_c()</div><div><br></div><div>2b) agreed but there is no reason for them to be disallowed except readibility but they should be discouraged </div><div>2c) see it might be okay, depending on what people think of your second question. in my opinion it should be illegal stylistically and be required to be changed to </div>

<div><br></div><div>def summation(start, end)</div><div>    i = start</div><div>    while i < end:</div><div>        start += i</div><div>        i  += 1</div><div>    return start</div><div><br></div><div>def a_func():</div>

<div>    # do stuff</div><div>    x = b given:</div><div>        b = summation(0, 100)</div><div><br></div><div><br></div>