Professional IronPython


Understanding the Use of Indentation and Capitalization in IronPython



Download 20,35 Mb.
Pdf ko'rish
bet54/453
Sana01.07.2022
Hajmi20,35 Mb.
#723045
1   ...   50   51   52   53   54   55   56   57   ...   453
Understanding the Use of Indentation and Capitalization in IronPython
 

 
31
UNdERSTANdINg THE USE oF INdENTATIoN
ANd CAPITAlIzATIoN IN IRoNPyTHoN
Most application programming languages have rules that help the compiler or interpreter under-
stand what you mean. For example, when working with C, C++, Java, C#, and a number of other 
languages, you use opening and closing braces to indicate the code that belongs within a structure 
such as a function or loop. Without these opening and closing braces, the compiler or interpreter for 
the target language would never be able to understand what you mean — these braces add structure 
to your application code. Likewise, IronPython relies on rules, indentation and capitalization, to 
help the interpreter understand your code.
The interpreter does help you with the indentation. The amount you indent a line doesn’t seem to 
matter. Using tabs instead of spaces doesn’t seem to matter either, but using tabs will ensure that 
you don’t run into problems seeing the indentation in code properly. Open a copy of IPY to follow 
along with the discussion in this section. Try the following steps and you’ll discover how the inter-
preter helps you discover when to indent. 
1.
Type 
SomeText = ‘Hello‘
and press Enter. You’ll see that the interpreter adds three 
greater-than signs (>>>). The >>> is a primary prompt and tells you that you don’t need to 
add any indentation.
2.
Type 
if SomeText == ‘Hello‘:
and press Enter. Now you’ll see that the interpreter adds 
three dots (
...
) to the next line. The 
...
is the secondary prompt. It tells you that you’ve 
entered a structure.
3.
Type 
print SomeText
and press Enter. The interpreter displays an error message like the 
one shown in Figure 2-12. The interpreter expected an indented block, but you didn’t pro-
vide any indentation, so the block failed.

Download 20,35 Mb.

Do'stlaringiz bilan baham:
1   ...   50   51   52   53   54   55   56   57   ...   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