You are allowed to code anywhere, at anytime you are not working. The difference is you get to choose. (Which can be a bad thing!)
I have turned down a number of jobs before because of a tricky/long commute (if I can't ride there, I am not interested), which has confused a number of HR/Agents. I value my time too much (unless they are paying me 1/4* as much, but they never are. Companies that are further away from the city (I always live near the center), are usually cheap in other ways too.
I tried coding on the bus, but the roads are too bumpy. Plus, my 1 hour commute involves three different lines, so I have to pack my stuff up twice to change busses. Another downside is that my ride takes me through one of the rougher neighborhoods of my town and somehow I wouldn't feel too comfortable with my laptop on my lap in that area.
you can't beat that!