First off you need to seperate those animals, a ball python should be housed by itself, and definatly not with a baerdie in the same tank... Ball pythons can fight with each other and do regularly display dominance over each other... If you ever see them laying together and one is on top of the other, the one on top is displaying dominance...
The snake that is giving you problems is probably very stressed out, they are very secretive creatures that enjoy solitude... Also a 40g long tank is too big, a 20g long tank will keep a BP for thier entire life.