My setting is inspired by fantasy-Persia: think Shahnameh, or if you're unfamiliar with that, 1001 Nights. Middle-eastern setting, no gunpowder. An element I want in my story is that people (noblemen and commoners alike) do not carry swords within city limits. It's supposed to tie into a strict cultural delimitation between war and peace. Exceptions would be border towns and city guards/palace guards. Also, a dagger would be different from a sword, and quite acceptable.
What conditions need to be met for this to work? Can city guard in that period be effective enough that a nobleman could walk around at night with the kind of money that a nobleman carries, and not be attacked? Or would I need some sort of better guarded "inner city", with only that area being sword-free? Are there any historical examples of similar laws in pre-modern times?