Q:

Comparing 2 files in Python while ignoring comments

Is there an easy way to compare 2 files in Python while ignoring certain lines? I want to ignore Python style comments (a line beginning with #) and check if all other lines are the same. I guess there's always reading the file line by line and manually comparing.

A:

First remove the comments from both files. Then use a Differ to compare the resulting files.

