can't figure out syntax prob
Robert Brewer
fumanchu at amor.org
Fri Nov 21 22:26:17 EST 2003
You need a colon after the parameter list:
class FileGroup:
sourceDir = ''
destinDir = ''
frequency = 1
recursive = False
def __init__(self, fg):
self.sourceDir = getSourceDir(fg)
self.destinDir = getDestinDir(fg)
self.frequency = getFrequency(fg)
self.recursive = getRecursive(fg)
Notice also that I indented the next line (sourceDir =
getSourceDir(fg)). I assumed it was part of the __init__ function?
You also probably meant to prefix the variables in __init__ with
"self.". This binds those values to each instance.
Robert Brewer
MIS
Amor Ministries
fumanchu at amor.org
> -----Original Message-----
> From: python newbie [mailto:mesteve_b at hotmail.com]
> Sent: Friday, November 21, 2003 7:18 PM
> To: python-list at python.org
> Subject: can't figure out syntax prob
>
>
> Can someone please tell me know what is wrong the code below.
> Whether I try
> to just execute this class definition in IDLE, or include in
> a py file that
> I attempt to run with python.exe, I get the error at the bottom.
>
> In case this formatting gets messed up after posting, the
> carrot is pointing
> at the second parenthesis.
> I saw in Quick Python book, that I can define an __init__
> function with more
> than argument.
> Thanks
>
> -------------
> class FileGroup:
> sourceDir = ''
> destinDir = ''
> frequency = 1
> recursive = False
> def __init__(self, fg)
> sourceDir = getSourceDir(fg)
> destinDir = getDestinDir(fg)
> frequency = getFrequency(fg)
> recursive = getRecursive(fg)
> ---------
>
>
> File "OregonBackup.py", line 23
> def __init__(self,fg)
> ^
> SyntaxError: invalid syntax
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list