Chapter 5. Interacting with Structures and Objects

WHAT'S IN THIS CHAPTER?

  • Using native IronPython objects

  • Creating your own classes and objects

Most developers work with structures and objects today because structures and objects focus on data, rather than on the procedure for modifying the data. Structures and objects are also extremely flexible when compared to procedures. In fact, if you've been programming for any time at all, you probably wouldn't be without structures and objects as part of your programmer toolbox.

Like all modern languages, IronPython provides the means for working with both structures and objects. In fact, a surprising number of the IronPython features you've already worked with are objects. For example, when you work with a string, you have access to a number of methods for manipulating the string. The "Performing a Simple Decision Using if" section of Chapter 3 is the first place in the book where you work with a string as an object, but it won't be the last. Because IronPython hides so many objects from view through sheer simplicity, the first section of this chapter discusses common IronPython objects and how to work with them.

Providing objects in IronPython wouldn't be very helpful if you couldn't create new objects of your own. After all, objects help you model the real world and make sense out of it from within an application. IronPython lets you create your own classes, derive objects from the classes, and use the objects with the same ease as built-in ...

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.