58
0.6.I
NSTALLINGON
O
THER
P
LATFORMS
Python3isavailableonanumberofdifferentplatforms.Inparticular,itisavailableinvirtuallyeveryLinux,
BSD
,andSolaris-based distribution.Forexample,RedHatLinuxusesthe
yum
packagemanager;FreeBSDhas
its
portsandpackagescollection;Solarishas
pkgadd
andfriends.Aquickwebsearchfor
Python 3
+your
operatingsystemwilltellyouwhetheraPython3packageis available,andhowtoinstallit.
⁂
0.7.U
SING
T
HE
P
YTHON
S
HELL
ThePythonShellis whereyoucanexplorePythonsyntax,getinteractivehelponcommands,anddebug
shortprograms.ThegraphicalPython Shell(named
IDLE
)alsocontainsadecenttexteditorthatsupports
Pythonsyntaxcoloringand integrateswiththePythonShell.Ifyoudon’talreadyhaveafavoritetexteditor,
youshould give
IDLE
atry.
Firstthingsfirst.ThePythonShellitselfisanamazinginteractiveplayground.Throughoutthisbook,you’llsee
exampleslikethis:
>>> 1 + 1
2
Thethreeanglebrackets,
>>>
,denotethePythonShellprompt.Don’ttypethatpart.That’sjusttoletyou
knowthatthis exampleismeanttobefollowed inthePythonShell.
1 + + 1
isthepartyoutype.YoucantypeanyvalidPythonexpression orcommandinthePythonShell.Don’t
beshy;itwon’tbite!Theworstthatwillhappenisyou’llgetanerrormessage.Commandsgetexecuted
immediately(onceyoupress
ENTER
);expressionsgetevaluatedimmediately,andthePythonShellprintsout
theresult.
2
istheresultofevaluatingthis expression.Asithappens,
1 + 1
isavalidPythonexpression.Theresult,of
course,is
2
.
29