Halloween can trip up even the most conscientious dieter. Last year, a client who had lost 20 pounds bought several bags of Snickers, her favorite candy bar, and began a binge that didn't end until the candy was gone -- long before trick or treat even began! That brought her weight up a couple of pounds. Then the holidays came, and before she knew it she had gained almost 10 pounds before winter was over.

With Halloween -- and holidays -- looming, it's important to determine your strategy for dealing with the temptation of sweets: what you eat, what you bring into your home and what you serve others. My philosophy is that all foods can be enjoyed in moderation. But there are special challenges posed with some foods, particularly sweets. Understanding the science behind sweet cravings and overeating can help us eat in a more moderate and healthy way.

People have an inborn attraction to sweets. Watch an infant's response: There's an automatic acceptance to eating something sweet. On the other hand, vegetables are an acquired taste, which may take a child 10 to 20 tries before acceptance. This is partly explained by evolution. We've been eating naturally sweet foods such as breast milk and fruit for hundreds of thousands of years. They contain life-sustaining nutrients, and a love for those foods helped keep us alive.

But there are other explanations. The research surrounding our attraction to sweets has stepped up in recent decades as scientists try to understand the calorie imbalances causing the obesity epidemic, which is partly fueled by eating too many sweets.

Our brain chemistry holds an important clue. Research shows that sugary sweets, which are simple carbohydrates, and many antidepressants both boost the brain chemical, serotonin, which helps regulate mood and appetite.

"Without carbohydrates, your brain is not able to make serotonin in optimal amounts," says Judith Wurtman, the director of the women's health research program at the Massachusetts Institute of Technology's Clinical Research Center in Cambridge, Mass. "Eating carbohydrates profoundly improves mood, which is why a handful of candy corn will make you feel better."

When we're stressed, anxious or depressed, serotonin levels can drop, and one way people modify their moods (consciously or not) is by eating carbohydrates, or in their purest form, sugar. But Halloween sweet cravings may be uniquely influenced by seasonal changes, too. Studies show that as days get shorter and we are exposed to less sunshine, brain serotonin activity may be affected. Since eating carbohydrates enhances serotonin synthesis, carbohydrate consumption may be a behavioral way to increase serotonin levels and improve our mood.

"If they sold Halloween candy in July, people wouldn't be as interested," says Wurtman.

Cravings and overeating are difficult to study because they can be so subjective and multifactorial. Other researchers stipulate sweet cravings are mainly determined by culture or by psychological and behavioral factors, rather than physiology. Chances are, a combination of factors is responsible for cravings and overeating sweets:

* Sex: Women are particularly vulnerable to sweet cravings because their brains have less serotonin than men, according to Wurtman. There have been other explanations for women's reported increased cravings for, and consequent indulgences in, sweets. Some researchers attribute the difference to the female hormone, estrogen. It's been reported that sweet cravings change according to where a woman is in her menstrual cycle and also with pregnancy, circumstantial evidence that estrogen may play a role. But the findings are inconsistent, as some report increased cravings during menstruation, while others report higher cravings as a premenstrual symptom, a time when serotonin levels may be low.

* Upbringing: Some studies report that exposure during childhood is the major determinant of what we crave and are susceptible to overeating. For example, I copied my mother's love for sweets and love of baking; it was a fun activity we did together. In college, to combat loneliness, and just for fun, I overindulged my love for sweets (as the pounds went up and up). I would regularly make my favorite chocolate chip bars and caramel popcorn, both of which I made when I was young.

* Availability and proximity: These factors probably trump all of the other reasons why we crave and overeat sweets. When tasty foods are around, we simply eat more of them. That's why Halloween is such a trap.

"Halloween candy is novel, it only comes around once a year. It comes in small pieces so you fool yourself into thinking you're not eating as much," says Wurtman. "You put it in bowls around the house and eat it mindlessly!"

Wurtman says if you have a strong desire for sweets, it may be a sign that you're depressed, anxious or stressed. But she insists you don't have to indulge in sweets to raise your serotonin levels to feel good. (For instance, sunlight boosts brain serotonin.) Also, exercising, stress management and spending time with loved ones are activities that will help reduce depression, anxiety and stress. (My client discovered a psychological basis for her binges, which she is successfully averting these days).

Using candy to feel better is not a great solution for your waistline or health. It is so high-calorie, it doesn't take much to overeat. For the same calories in a candy bar, you could eat four apples. Or maybe you couldn't -- and that's the point.

Katherine Tallmadge is a Washington nutritionist and author of "Diet Simple" (Lifeline Press, 2004). Send e-mails to her at food@washpost.com..