Current-limiting resistor on input pins?

When connecting a switch to an MCP23017, I usually insert a 200-300 R btwn switch and ground, to avoid shorting the pin if it was mistakenly programmed as output.

Question: is this good practice for switches connected directly to Arduino? Is it at all necessary? In other words: what happens if a pin programmed as output is switched directly to ground?

I have done a quick (probably too quick) search on the forum but not found an answer yet.

threegreens:
Question: is this good practice for switches connected directly to Arduino? Is it at all necessary? In other words: what happens if a pin programmed as output is switched directly to ground?

It may break due to too strong current.

There's supposedly a current limiter in the pins, but it's not guaranteed to have your pins survive what is effectively a short (either pin OUTPUT, HIGH connected to GND, or pin OUTPUT, LOW connected to Vcc).

There is no current limiter on Arduino pins.

To be completely safe, do not exceed one half the absolute maximum pin current (i.e. source or sink no more than 20 mA).

Thank you both!

So 330 ohm (15mA) should be safe enough.

The code to read a pin as a switch can easily be made compartmentalized enough that there is an almost zero probability of it being set as an output.

Correct! I do that. Problem is not the code. I keep plugging and unplugging modules and it is not inconceivable that one day a connector will get on the wrong pins.