Hi Robert On Thu, Apr 10, 2008 at 1:34 PM, Robert Kirkpatrick <[EMAIL PROTECTED]> wrote: > Hi All, > > Just wondering if there are any basic conventions for including code > snippets that are for testing / debugging only? > > For example, you could set a boolean variable called DEBUG, then have > snippets of code like: > > if DEBUG: > do stuff > else: > do otherstuff I'd do something like this:
from settings import DEBUG def my_user_list() # assumes long_list is already populated (db, file, etc) if DEBUG: return long_list[:5] else: return long_list def process(user): # do the work on the user here pass def main(): # ... [process(user) for user in my_user_list()] The idea is to encapsulate the retrieval of the user list and let that encapsulation hide the DEBUG logic. It could be done with a function, like above, or with a MyUserList class. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor