There is an error in first code snippet; put
from panda3d.core import *
at the top, then save it as a file called FirstPersonCamera.py
Save the second snippet as testfsp.py into the same directory and execute
ppython testfsp.py
To toggle FirstPersonCamera on/off, press .