[Tutor] problem with program

Alan Gauld alan.gauld at yahoo.co.uk
Fri Oct 13 13:53:50 EDT 2017


On 13/10/17 13:04, Chris Coleman wrote:

>     def_init_(self,chat):

> File "scripts/bird.py", line 4
>     def_init_(self,chat):
>                               ^
> SyntaxError: invalid syntax

There are two problems here.

The first is that you need a space after the def.
The second is that there should be two underscores
on each side of init, so:

def __init__(....):

The double underscore is a common structure in
Python that indicates a method that is handled
in a special way by Python, they are often
called "dunder" methods. But it often catches
beginners out, especially if your tutorial font
does not make the double underscore obvious.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list