Array

Performing Enumerations

Must Read

Admin
Admin
Just post!

You’re going to encounter a lot of enumerations before the book is over because IronPython uses them by the gross. Essentially, enumerating data means to obtain the individual elements from a collection or array and do something with them. One of the more common collections that you’ll enumerate is sys.path. Listing 3-7 shows a simple example of how this process might work.

Listin g 3-7: Using an enumeration

[code]

import sys
# Enumerate the path variables.
for ThePath in sys.path:
print ThePath
# Pause after the debug session.
raw_input(‘Press any key to continue…’)

[/code]

As you can see, the for…in loop comes in very handy for enumerating data. Depending on your configuration, you might not see all of the path information shown in Figure 3-5, but your output will look similar. The “Changing sys.path Values” section of Chapter 2 tells you more about each of the elements displayed in Figure 3-5.

You can find many uses for enumerations in IronPython.

- Advertisement -

Latest News

Unpacking Fixed Rate HELOCs: The Good, the Bad, and Everything In Between

Today, we're diving deep into the world of Fixed Rate Home Equity Lines of Credit (HELOCs). If you're a...
- Advertisement -

More Articles Like This

- Advertisement -