If coffee's your thing....your not going to do better than Lisbon. Remember, Brazil was a colony of Portugal, and they have a long and well-developed coffee culture.
Walking around Lisbon is great. Lisbon has a "San Francisco" feel with narrow streets, old canary-yellow trams rattling along steep hills that overlooking the ocean. And, Lisbon has a reputation as having hot culinary scene.
The weather in late October will be warmer and sunnier in Lisbon.