Q: Suppose $f:\mathbb{R}\rightarrow \mathbb{R}$ is measurable with respect to Lebesgue measure and $f(x)=f(x+1)=f(x+\pi)$ for almost every $x$. Prove that $f$ is constant almost everywhere.
Proof attempt: Since the ratio of $1$ and $pi$ is irrational, given any real number $r$ we have there exist $m, n\in \mathbb{Z}$ such that $|r-(m+n \pi )|< \epsilon$, so that the set $P=\{m+n\pi : m, n\in \mathbb{Z}\}$ is everywhere dense.
Now by Lusin's theorem take the interval $[a, b]$, so there is a compact set $E\subset [a,b]$ such that $\mu(E) > (b-a-\delta)$ for some arbitrarily small $\delta$ and so that $f|_{E}$ is continous. Pick a point $x$ like the one in the condition of the problem and any $y\in E$. By continuity of $f$ on $E$ and by the density of $P$ there will be a point such that $|f(x)-f(y)|=|f(x)-f(y)|=|C-f(y)|<\epsilon_{2}$. Taking the limit as $\delta \rightarrow 0$, $f$ is constant almost everywhere on the interval $[a, b]$, and since the interval is arbitrary we can say $f$ is constant almost everywhere.
Does this look alright? Is there another way of doing this without invoking something like Lusin's theorem? Measurable functions can be very ugly, so are there any other results similar to Lusin's theorem that allow us to put some sort of regularity on measurable functions and gain some intuition about them?
Thanks in advance!