Python Programming for Biology: Bioinformatics and Beyond



Download 7,75 Mb.
Pdf ko'rish
bet31/514
Sana30.12.2021
Hajmi7,75 Mb.
#91066
1   ...   27   28   29   30   31   32   33   34   ...   514
Bog'liq
[Tim J. Stevens, Wayne Boucher] Python Programming

Whitespace matters

One  of  the  fundamental  design  decisions  Guido  van  Rossum  made  when  designing  the

Python language was to designate different blocks of code using the space at the beginning

of lines, rather than using curly braces/brackets as many other languages use (e.g. C, Perl,

Java etc.). Thus the space at the beginning of a line matters in terms of how the following

commands are interpreted. Space can be added by pressing the space bar or the Tab  key,

and moves the characters which follow to the right. Things like space and tab, which have

no  printed  symbol,  are  often  still  considered  as  ‘characters’  in  computing  and  are

collectively  referred  to  as  ‘whitespace’.  If  you  have  too  little  or  too  much  whitespace  at

the beginning of a line you get a syntax error. The syntax error indicates that the Python

interpreter was unable to process the input characters in a meaningful way.

>>> 2+2


4

>>> 2+2


File "", line 1

2+2


^

IndentationError: unexpected indent

>>>



Note  that  whitespace  after  the  beginning  of  a  line  does  not  matter  (between  tokens  of

the language):

>>> 2 + 2 # this is same as 2+2

4

>>>



Because whitespace at the beginning of a line is required to delineate blocks of code, as

we illustrate later, it can be somewhat problematic if not used appropriately. In particular,

you  should  never  mix  tabs  with  ordinary  spaces  (and  from  Python  3  this  is  illegal),

because on some machines a tab may be equivalent to four spaces, but on others it may be

eight, so code could break moving it from one machine to the next. In many text editors

you can automatically convert tabs to ordinary spaces (sometimes this is called using ‘soft

tabs’) and that is what we recommend.


Download 7,75 Mb.

Do'stlaringiz bilan baham:
1   ...   27   28   29   30   31   32   33   34   ...   514




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