Here's something I tried w/my niece the first time she pet my snake, & also something we saw when we visited a local museum "mystery animal show" (where we got to pet a snake):

The "two finger rule"; the child can only pet the snake/lizard/etc with two fingers only, & of course no fast movements, etc.

Seems to work pretty well, & she was good about it too.