Eric Walstad wrote: > 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.
I would encapsulate the retrieval but not the DEBUG. My preference would be to have a separate main() in a test module that trims the user list. Then the DEBUG setting is not needed at all. Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor