[Tutor] G'day
Michael Lange
klappnase at freenet.de
Wed Feb 15 13:42:43 CET 2006
On Wed, 15 Feb 2006 22:05:39 +1100
"John Connors" <oztriking at hotmail.com> wrote:
> G'day, I'm new to Python and new to the list and just thought I'd say a quick hello before asking my 1st dumb question. My name is John and I live in Australia, I've been using computers since about 1983. I haven't done any programming since the commodore 64 basic days, I was fairly proficient with basic so I'm hoping I can pick up python without too much grief. I'm running Fedora Core 4 and using Python 2.4.1. My 1st dumb question: I have a copy of Teach Yourself Python in 24 Hours, printed in 2000 so I guess it's virtually usless but i was hoping to learn some of the basics from it. There is a small bit of code near the beginning... print "Hello, World!"print ' 'Goodbye, World!" which returns a syntax error for the 2nd line. I thought it was a typo and changed it to print "Goodbye, World!". This would be fine except further on the book there is similar syntax in some of the longer scripts. My guess is that syntax was ok for an older version of Python that book was written for. I would like to know what the correct code should be. John
Hi John,
I don't think the book is completely useless, it just misses the features added to python since 1.5.2;
it was my first book, too, and I think it's still fine to learn the basics.
I don't have it at hand right now, so I cannot look for your example, and mine is a german copy, so it probably
won't have the same typo. If the code example looks like:
print "Hello world"
print ''Goodbye world"
it's a typo.
It is just a guess, maybe the example later in the book looks rather like:
print 'I say "Hello world"'
or
print "You say 'Goodbye world'"
?
In python you can use both single (') or double (") quotes to delimit a string, but you need to use the same
character both at the beginning and the end of the string. The character that is not used to delimit the string
can be used inside the string.
I hope this helps
Michael
More information about the Tutor
mailing list