That was a big one! Pantry-pythons sure can make a mess of your shelves, Instead of risking a bite to his face, what I'd have done is to offer the snake a length
of 4" (diameter) PVC drain pipe to hide in...I bet he'd have happily taken the suggestion, & then the pipe could just be capped temporarily & later just laid on the ground
for the snake to leave gracefully on his own. I have removed a few snakes too in my time, lol. Rattlesnakes though, not "pantry-pythons".