The discounts get the customers flooding in

Once word gets out that there are double-discounts available in the coffee bar, the health club gets packed with customers.

We've never been so busy! The weight room, the gym, the steam baths. The whole place is full of customers! I like the way you write code. I want you to upgrade every system in the place!

Thanks to writing modular code, you got the contract to replace all the health club systems. Modules help you write stable, maintainable code. The more code you write in modules, the greater the chance that you'll be able to reuse it elsewhere.

Breaking your code into modules turns good programs into great programs.

Dumb Questions

A" You use a Fully Qualified Name (or FQN) when you need to distinguish between two functions from different modules that have the same name. With the health club systems, the discount () function existed within your module and within the one supplied by Starbuzz. In order to keep things straight, you had to use a FQN.

Q," So if I hadn't used a FQN, the wrong discount is applied to the purchase?

Yes, most probably.

Q," But if I hadn't used a FQN, how would I know which discount was used?

A" Well... that's the problem. You wouldn't. It's hard to predict what would happen, because it all depends on which order the code imports its modules.

Q/ So, all I need to do is keep an eye on the order when I import modules and everything will be OK?

A" No, that's not what we recommend. Don't rely on what might happen. Use a FQN so that you are always in control.

We've never been so busy! The weight room, the gym, the steam baths. The whole place is full of customers! I like the way you write code. I want you to upgrade every system in the place!

programming toolbox

Your Programming Toolbox

You've got Chapter 6 under your belt. Let's look back at what you've learned in this chapter:

Python "fools

* Use "A* ... import to run ┬┐ode module functions without module names.

* Wse w ..." if you ,eed to <M*y your function names With a module name using an

W Uich is the recommended approach in the python Community).

7 building a graphical user interface

Was this article helpful?

0 0

Post a comment