[Tutor] Quick question about definitions.
Steven D'Aprano
steve at pearwood.info
Sun Nov 18 03:12:07 CET 2012
On 17/11/12 04:28, sillywilly98 wrote:
> I know this code is not fully debugged. I just cant see why 1 definition is
> wrong.<http://python.6.n6.nabble.com/file/n4996080/def.png>
Please don't send screen shots if you don't need to. In this case, the screen
shot adds nothing, and turns this into a "long question" instead of a "quick
question".
When you try to run the code, Python will print an error message as text,
which you can easily copy and paste into your email. You should get something
like this:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "test.py", line 20
def draw_nose():
^
SyntaxError: invalid syntax
That is MUCH quicker and simpler than:
* take a screen shot
* crop it
* save it to a file
* upload it to nabble.com
* copy the URL
* send the URL in an email
* hope that people will click on the url
* and that nabble isn't blocked for them (many people can receive email
but have all or parts of the web blocked)
* hope that they can guess what editor you are using
* hope that they can guess why the editor has coloured "def" red
* or yellow-grey-brown, if they are colour-blind[1]
In this case, the solution is simple: the previous line to the def
is missing the closing parenthesis:
end_fill(()
Unfortunately, when there is a missing bracket of any type, whether
round ), square ] or brace }, the Python interpreter cannot tell it
is missing until it reaches the *next* line. So often when you have
a SyntaxError, it is on the line after the line with the actual
problem.
[1] Software developers: if your software uses colour *alone* to
represent information, you are doing it wrong. About 8% of men
and 0.5% of women have red-green colour-blindness, with other
forms being less common. All up, about 1 in 10 men and 1 in 100
women cannot easily or at all distinguish colours.
http://en.wikipedia.org/wiki/Colour_blindness
--
Steven
More information about the Tutor
mailing list