Matthew Wilson wrote: > I'm interested to hear how other people deal with really similar > code. > The similarity just bugs me. However, I wonder if using stuff > like closures or partial function application is needlessly showy.
ACK -- but not because it's showy, but because it may be more error-prone and less readable. I'd often use an approach like this: def create_user(username, userpassword, useremail, create = False): """ Send an email that will update a user in the remote system. If create evaluates to True, don't update the user, but create her instead. """ if not create: subject = "UPDATE" else: subject = "CREATE" # Build email email_body = """ USERNAME = %s USERPASSWORD = %s USEREMAIL = %s """ % (username, userpassword, useremail) # send it. send_email(subject=subject, body=email_body) Regards, Björn -- BOFH excuse #353: Second-system effect. -- http://mail.python.org/mailman/listinfo/python-list