[Edu-sig] C++ As a First Language

Ulf Engström ulf.engstrom@b2b-link.com
Thu, 2 Mar 2000 09:26:50 +0100


This is a multi-part message in MIME format.

------=_NextPart_000_0022_01BF8429.70365E00
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Tim Peters:
>> name =3D input("Please enter your first name:")
>> print "Hello", name

Bob Kummerfeld:
>...but did it run? Did you mean to use "raw_input"?

It runs, the difference between input and raw_input in matter of use is =
just that when you use just plain input you'll have to add ' or " to =
your reply if it's made up of chars.

>>> name =3D input("Please enter your first name:")
Please enter your first name:Ulf
Traceback (innermost last):
  File "<pyshell#0>", line 1, in ?
    name =3D input("Please enter your first name:")
  File "<string>", line 0, in ?
NameError: Ulf

>>> name =3D input("Please enter your first name:")
Please enter your first name:'Ulf'
>>> name
'Ulf'

>>> num =3D input("Please enter a number:")
Please enter a number:5
>>> num
5

>>> name =3D raw_input("Please enter your first name:")
Please enter your first name:Ulf
>>> name
'Ulf'

Conclusion: Unless you're dealing with numbers-only, use raw_input. =
Still it's a lot easier than starting with C++, which was one of my =
first languages. ;)
Regards
Ulf Engstr=F6m

------=_NextPart_000_0022_01BF8429.70365E00
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2919.5500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Tim Peters:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&gt;&gt; name =3D input("Please enter =
your first=20
name:")</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&gt;&gt; print "Hello", =
name</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Bob Kummerfeld:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&gt;...but did it run? Did you mean to =
use=20
"raw_input"?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>It runs, the difference between input =
and raw_input=20
in matter of use is just that when you use just plain input you'll have =
to add '=20
or " to your reply if it's made up of chars.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&gt;&gt;&gt; name =3D input("Please =
enter your first=20
name:")<BR>Please enter your first name:Ulf<BR>Traceback (innermost=20
last):<BR>&nbsp; File "&lt;pyshell#0&gt;", line 1, in =
?<BR>&nbsp;&nbsp;&nbsp;=20
name =3D input("Please enter your first name:")<BR>&nbsp; File =
"&lt;string&gt;",=20
line 0, in ?<BR>NameError: Ulf<BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&gt;&gt;&gt; name =3D input("Please =
enter your first=20
name:")<BR>Please enter your first name:'Ulf'<BR>&gt;&gt;&gt;=20
name<BR>'Ulf'<BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&gt;&gt;&gt; num =3D input("Please =
enter a=20
number:")<BR>Please enter a number:5<BR>&gt;&gt;&gt; =
num<BR>5</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&gt;&gt;&gt; name =3D raw_input("Please =
enter your=20
first name:")<BR>Please enter your first name:Ulf<BR>&gt;&gt;&gt;=20
name<BR>'Ulf'</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Conclusion: Unless you're dealing with=20
numbers-only, use raw_input. Still it's a lot easier than starting with =
C++,=20
which was one of my first languages. ;)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Regards</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Ulf =
Engstr=F6m</FONT></DIV></BODY></HTML>

------=_NextPart_000_0022_01BF8429.70365E00--