Detect if interactive or script mode

I have used hasattr(sys, "ps1") many times in the past for this purpose