If your code is not sensitive information, it might help us if you post it to pastebin or something so we can take a look.<div>In general though, functions should be as long as they need to be (and no longer!).  57 lines is not inordinately long.  If it&#39;s hard for you to read, though, you should refactor it.</div>
<div><br></div><div>I&#39;d say my personal hard-limit for functions before I start refactoring is probably around 150-200 lines.  But it&#39;s rare that functions get that long anyway.</div><div>Remember to think of them as reusable units of code that do one specific procedure.  Once you move into OO your functions will probably end up being rather small as well, that paradigm encourages many small functions interacting.<br>
<br><div class="gmail_quote">On Mon, Dec 7, 2009 at 7:37 PM, Che M <span dir="ltr">&lt;<a href="mailto:pine508@hotmail.com">pine508@hotmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">




<div>
I have some functions that seem kind of long to me.  One of them, with<br>white space, comments, print statements, and some commented-out lines,<br>is 118 lines long.  If I remove all that, it is 57 lines long.  I get the sense<br>
that is inappropriately long for a Python function.  <br><br>The length of it is due to a number of if statements--things it needs to<br>check in terms of the state of the app at the time it is called.  So there<br>are a number of conditional (and &quot;subconditional&quot;) parts to it, and what<br>
it does in response to those conditions.  In fact the word &quot;if&quot; appears in<br>it 12 times.  <br><br>I realize I can and should refactor parts that are used in other places<br>in the code, but I don&#39;t there are that many in some of these.  Is<br>
there a better way to think about organizing this?<br><br>Thanks,<br><font color="#888888">Che<br>                                               </font><div class="hm"><br><hr>Windows Live Hotmail gives you a free,exclusive  gift. <a href="http://www.microsoft.com/windows/windowslive/hotmail_bl1/hotmail_bl1.aspx?ocid=PID23879::T:WLMTAGL:ON:WL:en-ww:WM_IMHM_7:092009" target="_blank">Click here to download.</a></div>
</div>
<br>_______________________________________________<br>
Tutor maillist  -  <a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
<br></blockquote></div><br></div>