fix arguments to isinstance() in env lookup

Arguments to isinstance() appear to be the wrong way round, and was throwing an error for me.

P.S. New to github and hope I've got this pull request stuff right.