On 28/09/2012 10:04, Stuart Parker
wrote:
Hi Lawrence, here's what i've got - i'm pretty sure
it's not wrong but it's come down to this!
developer_id = "my developer id"
secret_key = "my secret key"
if developer_id == "my developer id":
import sys
print "You must specify your developer information
in " + __file__
sys.exit(1)
Stuart,
A pro tip (from a marine botanist that now writes software for a
living - self taught), read the code as English. If it doesn't make
sense it is probably wrong.
Remember that in Python, indentation is significant, so read those
indented lines as a paragraph. If the paragraph "header" has little
to do with the paragraph, it probably is wrong in some way.
With that in mind, lets take a look at your code:
developer_id = "my developer id"
secret_key = "my secret key"
According to the docs, these things should be changed to your
specific variables (in a different file in the examples, but this
will work too)
if developer_id == "my developer id":
Read this as English - 'if the variable developer id is "my
developer id" then do the following:'
so we can see that already everything below that and indented will
be ignored since you have changed "my developer id" to your actual
developer id right? ;)
That then means that your code is the wrong way around.
Lets change it around a bit for you then:
developer_id = "id1234"
secret_key = "s7890"
if developer_id == "my developer id":
print "Oops, you forgot to set your key!"
sys.exit(1)
else:
import sys
print "Al clear, lets start the code of my actual
programme now!"
# Carry on now with the rest of your code...
...
...
Hope this clears up some confusion for you at least!
Also, read the docs on
python.org and dive into python as a starting
point. They are really useful resources and I do believe that there
is still a "Python for non-programmers" doc as well.
-- Paul