I am trying to create a virus scanner in Python, and I know that signature based detection is possible, but is heuristic based detection possible in Python, ie. run a program  in a safe environment, or scan the program's code, or check what the program behaves like, and then decide if the program is a virus or not.
Yes, it is possible.
...and...
No, it is probably not the easiest, fastest, best performing, or most efficient way to accomplish the task.
Is it possible to implement heuristic virus scanning in Python?