Help for a complete newbie

R

Ralph H. Stoos Jr.

All,

I am reading a Python tutorial for complete non-programmers.

The code below is so simple as to be insulting but the assignment of the
"ready" variable gives a syntax error.

The code reads letter-for-letter like the tutorial states.

Here is a dump. Can anyone tell me what is wrong?

***************************************************

print " "
print "This \"autotp\" program will create raw bitmap test pattern images."
print " "
print "Please read the information below thoroughly:"
print " "
print "1. Graphic files MUST be TIFF images."
print "2. Images MUST have been ripped though a Nuvera system as a Print
and Save job"
print "3. Images should already be named with the desired file name."
print "4. The Lead Edge and file name should be identified in the image."
print "5. The name includes the purpose for, resolution of, side, and
paper size"
print "6. Images should be rotated to print correctly from Service
Diagnostics."
print " "
print "EXAMPLE: Bypass_BFM_Damage_1200x1200_Letter.tif"
print " "

# Get the decision if operator is ready
ready = raw_input("Ready to proceed ? TYPE (y)es or (n)o: ")

if ready == "y":
print "You are Ready"
else:
print "Try again"

OUTPUT from execution

File "autotp.py", line 21
ready = raw_input("Ready to proceed ? TYPE (y)es or (n)o: ")
^
*******************************************************************

Please respond to the group and to: (e-mail address removed)

Thanks,

Ralph
 
J

John Machin

All,

I am reading a Python tutorial for complete non-programmers.

Would you mind providing a URL for the tutorial? It's vaguely possible
that we may be able to recommend a slightly better tutorial :)
The code below is so simple as to be insulting but the assignment of the
"ready" variable gives a syntax error.

The code reads letter-for-letter like the tutorial states.

Maybe it's not character-by-character :)
Here is a dump. Can anyone tell me what is wrong?

***************************************************

print " "
print "This \"autotp\" program will create raw bitmap test pattern images." [snip]
print "EXAMPLE: Bypass_BFM_Damage_1200x1200_Letter.tif"
print " "

# Get the decision if operator is ready
ready = raw_input("Ready to proceed ? TYPE (y)es or (n)o: ")

Problem is that the above line is indented relative to the previous
material line (the one with a bare "print" statement). Remove the indent
from here on, or indent all that print cruft.
 
S

Steve Bergman

The indentation is wrong. Python cares about indentation.


print " "
print "This \"autotp\" program will create raw bitmap test pattern
images."
print " "
print "Please read the information below thoroughly:"
print " "
print "1. Graphic files MUST be TIFF images."
print "2. Images MUST have been ripped though a Nuvera system as a
Print
and Save job"
print "3. Images should already be named with the desired file name."
print "4. The Lead Edge and file name should be identified in the
image."
print "5. The name includes the purpose for, resolution of, side, and
paper size"
print "6. Images should be rotated to print correctly from Service
Diagnostics."
print " "
print "EXAMPLE: Bypass_BFM_Damage_1200x1200_Letter.tif"
print " "

# Get the decision if operator is ready
ready = raw_input("Ready to proceed ? TYPE (y)es or (n)o: ")

if ready == "y":
print "You are Ready"
else:
print "Try again"
 
T

Tim Roberts

Ralph H. Stoos Jr. said:
I am reading a Python tutorial for complete non-programmers.

The code below is so simple as to be insulting but the assignment of the
"ready" variable gives a syntax error.

The code reads letter-for-letter like the tutorial states.

Letter for letter, maybe, but not space for space. Indentation is
important in Python. The "ready =", "if ready", and "else:" statements
must start in column 1. The two print statements need to be indented, as
they are.
 
R

Ralph H. Stoos Jr.

Tim,

After a little more research, I did find that out. It is funny, but in
the tutorial "Non-Programmers Tutorial For Python", it makes no mention
of the indentation issue, at least in the beginning portions which I had
read.

This is an age old problem of learning. Once you know something, much
of it seems simple and the knowledge of it can become assumed. One of
the first things that should be done when providing training is to
assess your audience.

I am going to pick up a book like "Beginning Python" or "Learning
Python" this weekend.

Thanks so much for the info. Newsgroups are a great source of info, and
folks like yourself are the reason why this is true.

Best Regards,

Ralph
 
S

Steve Bergman

You can also access this group through Google Groups:

http://groups.google.com/group/comp.lang.python

which has nice search features.

I found O'Reilly's "Learning Python" to be helpful in combination with
O'Reilly's "Python in a Nutshell". Learning python is a nice
introduction to Python but is (intentionally) *far* from complete.
Python In a Nutshell is a reference work. The two complement each
other nicely.

Both are a bit out of date. The current python version is 2.4.
Learning Python covers 2.3. Nutshell covers up to 2.2.

One of these days Alex will come out with a 2nd Edition of Nutshell and
there will be much rejoicing. ;-)
 
S

Scott David Daniels

Steve said:
One of these days Alex will come out with a 2nd Edition of Nutshell and
there will be much rejoicing. ;-)
Rumor has it he is trying to hit print for OSCON (so soon, soon).

--Scott David Daniels
(e-mail address removed)
 
G

gene tani

Ralph said:
Tim,

After a little more research, I did find that out. It is funny, but in
the tutorial "Non-Programmers Tutorial For Python", it makes no mention
of the indentation issue, at least in the beginning portions which I had
read.

This is an age old problem of learning. Once you know something, much
of it seems simple and the knowledge of it can become assumed. One of
the first things that should be done when providing training is to
assess your audience.

There are only a few FAQ / gotchas lists for python <wink>:

http://www.ferg.org/projects/python_gotchas.html
http://zephyrfalcon.org/labs/python_pitfalls.html
http://zephyrfalcon.org/labs/beginners_mistakes.html
http://www.python.org/doc/faq/
http://diveintopython.org/appendix/abstracts.html

http://blog.ianbicking.org/my-python-4k.html

http://www.onlamp.com/pub/a/python/2004/02/05/learn_python.html
http://www.norvig.com/python-iaq.html
http://www.faqts.com/knowledge_base/index.phtml/fid/245
http://www.faqts.com/knowledge_base/index.phtml/fid/199

http://amk.ca/python/writing/warts
http://c2.com/cgi/wiki?PythonProblems
 
A

Alex Martelli

Steve Bergman said:
Both are a bit out of date. The current python version is 2.4.
Learning Python covers 2.3. Nutshell covers up to 2.2.

One of these days Alex will come out with a 2nd Edition of Nutshell and
there will be much rejoicing. ;-)

If everything goes according to plan, the Nutshell's 2nd Edition should
be out at OSCON (O'Reilly's Open Source Convention, end of July in
Portland, OR -- check it out, it's really a good conference!). The
book's text is about ready to get into O'Reilly's production queue (and
they take about 3 months to get to paper, so we should make it), save
for a few technical issues with cross-chapter cross-references, and
we're working on those; so it's basically out of my hands, save for
various intermediate-checking stages.

"Python in a Nutshell", 2nd edition, focuses on Python 2.4, but I've
managed to just about cover the forthcoming 2.5 as well (currently out
in alpha-1 stage) -- no doubt some 2.5 details in the book will prove
incorrect (particularly if there are any changes between alpha1 and the
final version), and for some crucial new libraries due for inclusion in
2.5 (such as ElementTree and ctypes) I've just barely managed a
"mention" rather than real "coverage"; nevertheless, I do hope the
amount of 2.5 coverage I've been able to add will be useful to future
readers (and save me from doing a 3rd edition any time soon;-).


Alex
 
F

fatal.serpent

There was an extra space before ready. It works otherwise. Use the code
below or just remove the space.
Heres the fixed code:
ready = raw_input("Ready to proceed ? TYPE (y)es or (n)o: ")

if ready == "y":
print "You are Ready"
else:
print "Try again"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,480
Members
44,900
Latest member
Nell636132

Latest Threads

Top