On Mon, Aug 2, 2010 at 13:48, Evert Rol <evert....@gmail.com> wrote: > (replying to the full list; hope that was intended.) > >>>> I was wondering how can I change sys.exit so if you use command line to >>>> run the program. it prompts a message asking if the user wants to exit >>>> instead of automatically just exiting? >>> >>> Just write a wrapper exit() function around sys.exit that does that. >> >> In a post 2 minutes after yours, Steven D'Aprano says, "write your own >> quit() function that >> asks the user and then calls sys.exit if they say yes." >> >> Is that an example of what you meant by a wrapper? I've never been >> sure I understood the term, "wrapper". > > Yes. A "wrapper function" would be a function that "wraps itself around" > something else, most of the time around another function. It's often used to > expand original functionality of a function, or to make life easier it you > need to always set some variables before calling the original function. > In Python, you could almost call it a decorator, although in this case that > wouldn't be a good idea. And wrapper function (as far as I'm aware) is a more > general term. > > For fun I just Googled for "wrapper function" (always useful). First hit > leads to wikipedia: http://en.wikipedia.org/wiki/Wrapper_function (though > it's a short wiki entry, and I'm not sure how much extra it would clarify).
Thanks, Evert, for your explanation. A big help. Dick _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor