I keep coming across this term hooks in various programming articles. However I don't understand what they are, and how can they be used. So I just wanted to know what is the concept of hooks; if someone could link me to some examples, particularly in the context of web development, it would be great.
closed as too broad by gnat, MichaelT, Bart van Ingen Schenau, GlenH7, ChrisF♦ Jan 6 '14 at 21:05
There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs. If this question can be reworded to fit the rules in the help center, please edit the question.
My answer pertains to WordPress which is written in PHP, but this is a general development mechanic so it shouldn't really matter, despite the fact that you put 'python' in your question title.
One good example of usage of hooks, coincidentally in web development, are WordPress' hooks.
They are named appropriately in that they allow a way to 'hook into' certain points of the execution of a program.
So for example, the wp_head is an 'action' that is emitted when a WordPress theme is being rendered and it's at the part where it renders the part that's within the
Now, when WordPress emits this action by doing something like
Long story short: It allows you to add additional functionality at specific points of the execution of a program by 'hooking into' those points, in most cases by assigning a function callback.
Depending on the background of the person asking sometimes the answer to this question can be as simple as hooks are usually another word for an event handler, which Blaenk gave an excellent explanation for.
There are also uses of this phrase that are when you inject an event or code into a process that otherwise does not have events like moles for example.