The Mayor of Py Town's Local Experiment: A Global Disaster
Why variables within functions are local • [This short article has a different style and format from the usual articles]
Py Town is a tranquil place. Time runs a bit slower here. Or so it seems. Nothing much ever happens in this town.
Crime is low. People are happy. The mayor was bored. So he kept himself busy by thinking of new plans for the town.
And that's when the problems started.
The mayor's idea was to make every item in Py Town available to every resident at all times.
Py Town had just been granted Tier 1 Magical Status from the regional authorities. This had been the mayor's pet project since he was first elected. He persisted through two failed applications. The third time was lucky, indeed.
Tier 1 Magical Status only grants the town relatively low-level magical powers. One day, he'll try to get Tier 2. But not just yet. Tier 1 was perfect for his new scheme to make every item available to everyone when they need it. The mayor was sure that Py Towners would be so grateful once they got used to the efficiency of this new plan. And the next mayoral election is only a year away.
What could go wrong?
Theo was sure he had just packed three loaves of bread in the basket. Meg would be collecting her order any time now. But there were only two loaves in the basket. And he could see Meg crossing the road and heading towards his bakery. Where's the missing loaf? He looked around on the worktop but couldn't find it.
Ines is the teacher in the primary school three blocks away from Theo's bakery. She had instantly fetched a loaf of bread using the mayor's new scheme. She was impressed. All this magic was still new to everyone. She had just saved herself a twenty-minute round trip to buy bread. She had also magicked the money directly to Theo's cash register, of course. She could start preparing lunch right away.
But Ines was less impressed after the lunch break when she tried to set up for the art lesson. She couldn't find the paintbrushes and watercolours. She's always meticulous and stores the art supplies in the green drawer. But the green drawer was empty.
Gustav, the local artist, started panicking. He was running his first-ever workshop for customers. Ten eager students were about to arrive at his studio any minute. He didn't have enough paintbrushes and watercolours for everyone. Luckily, he knew that his friend Ines had plenty of supplies at the school. He didn't have time to go to the school where Ines teaches, but he could magically borrow them instantly. Thank you, mayor, for the new scheme! He'll magically put them back at the end of the workshop. He didn't know Ines was planning an art lesson, though.
But Gustav's laptop was running low on power, and the charger was missing. Gustav's brother, Karl, was at the fancy coffee shop overlooking the park. Karl's laptop charger wasn't working, but he had to finish three urgent emails, so he thought he'd borrow Gustav's charger. They used the same laptop model. The mayor's new scheme was working well, Karl thought.
Items kept disappearing all day all over town as Py Towners started to use the mayor's new scheme. Every item in Py Town could be anywhere at any time. It didn't take long before chaos reigned. Services started to break down. People were getting more frustrated by the minute. Everything ground to a halt.
The mayor's re-election prospects weren't looking so good now.