Learned optimism is the idea in positive psychology that a penchant for joy and optimism can be cultivated. It is contrasted with learned helplessness. Learning optimism is done by consciously challenging any negative self talk.
Pessimism is essentially a bad habit or bad programming that was developed from being exposed to poor examples from parents, teachers or others who provided major influences during the formative years of our lives. Many of the negative command phrases that create the ill effects on our lives today were exactly the ones we heard verbalized by the influential people in our past.
Thinking patterns were developed and reinforced by repetitious example. By the time we reach adulthood these patterns have become deeply entrenched and woven into the fibre of our personalities, values and concepts. Rather than seeing the true nature of an uncomfortable situation, these patterns superimpose themselves onto our perception of reality, like Pavlovian conditioning (classical conditioning) and we may react as though we are powerless to change the outcome. This programming is used very successfully in training animals that can easily overpower their master, but it is disastrous as a problem solving mechanism for individuals in the throws of daily existence.
The manner in which you explain (self talk) how and why any unpleasant situation came about determines whether you are operating from the vantage point of helplessness or power and optimism.
In light of this knowledge it is then apparent that what is necessary for us to do is to unlearn the poor programming and reinstall more positive and productive patterns. Essentially, you must learn optimism. This begins with identifying your automatic thoughts, becoming aware of how they influence your moods and behaviours. Once identified they can be uprooted and replaced with the programming of your own choice. This gives you the freedom to propel your life in the direction that you choose rather than the direction chosen by unfortunate circumstances and influences of the past.