Professional IronPython


Working with Tuples, Lists, and Arrays



Download 20,35 Mb.
Pdf ko'rish
bet79/453
Sana01.07.2022
Hajmi20,35 Mb.
#723045
1   ...   75   76   77   78   79   80   81   82   ...   453
Working with Tuples, Lists, and Arrays
 

 
59
decide to use it to store integer values. You must also import the 
array
module to use IronPython 
arrays
, because 
arrays
aren’t part of the initial interpreter configuration. Listing 4-3 shows an 
example of an 
array
in use.
lISTINg 4-3: 
 Working with an actual array in IronPython
import array 
# define a local version of array.
array = array.array 
# Create a character array and assign it some values.
MyArray = array(‘c’, ‘Hello World’)
# Display each list element.
for TheCharacter in MyArray:
print TheCharacter 
# Pause after the debug session.
raw_input(‘Press any key to continue...’)
The example begins by importing the 
array
module and then assigning the 
array.array
method to 
a local variable. You’ve seen this kind of code before with the 
sys
module in previous chapters.
At this point, the code creates a character 
array
. Now it may appear that this 
array
contains a 
string, but what it really contains are individual characters. When you output the 
array
, you see the 
individual characters, as shown in Figure 4-3. Consequently, most developers of other languages are 
going to view the IronPython 
array
as a sort of byte 
array
.
FIguRE 4-3: 
Arrays handle sequences of values.
548592c04.indd 59
2/24/10 12:47:34 PM
www.finebook.ir


60

CHAPTER 4
Using ArrAys And ColleCtions
After reading this section, you might find yourself a bit confused, especially if you’ve worked with 
Visual Basic.NET or C# in the past where 
arrays
really are 
arrays
. What you’ll want most often 
is a 
list
in IronPython and you’ll likely use a 
tuple
in some situations as well. When you think 
array
for IronPython, think about these two kinds of objects. On the other hand, when you really 
do need to work with individual bits of data, then think about the IronPython 
array
because it does 
work with those individual sequences. 

Download 20,35 Mb.

Do'stlaringiz bilan baham:
1   ...   75   76   77   78   79   80   81   82   ...   453




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish