Performing Enumerations

Must Read

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


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…’)


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

Challenge new enemies in MIR4! New raid and boss raid revealed!

Wemade's blockbuster MMORPG MIR4 revealed a new raid and boss raid on Nov 29. In Vipergeist Prison, the new 14th...
- Advertisement -

More Articles Like This

- Advertisement -