Chapter 3. Implementing Structured Language Elements

WHAT'S IN THIS CHAPTER?

  • Creating applications that use multiple statements

  • Developing applications that select between options

  • Working with loops in applications

  • Enumerating data within applications

Up to this point, the sample applications have focused on simple tasks that didn't require much structure. However, real applications solve complex problems that often require decision making and loops. Performing these tasks requires structure within the application. The IronPython interpreter must know where the decision-making process and the loops begin and end. Consequently, you must know how to add structure to your application.

This chapter discusses four levels of structure. First, you'll see how to string a number of statements together in a structured manner. You've already seen some examples of this kind of structure in Chapters 1 and 2, but this chapter goes further. Second, you'll see how to create decision-making structures so that the application can choose between options. Third, you'll discover two looping mechanisms provided by IronPython. And fourth, you'll see how to enumerate data within applications — one of the more important structural techniques.

After you complete this chapter, you might be tempted to ask whether this is all that IronPython provides in the way of structures. It's true that IronPython does provide a few more advanced structural elements not discussed in this chapter, such as the with keyword. However, ...

Get Professional IronPython™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.