assign class variable in __init__

Mark Lawrence breamoreboy at yahoo.co.uk
Tue Jun 8 12:24:55 EDT 2010


On 08/06/2010 17:04, Ross Williamson wrote:
> Hi Everyone,
>
> Just a quick question - Is it possible to assign class variables in
> the __init__() - i.e. somthing like:
They're instance variables, not class variables.
>
> def __init__(self,self.source = "test", self.length = 1)
No.
>
> rather than
>
> def __init__(self,source = "test", length = 1):
>
>
Why not try this from an interactive prompt, quicker than posting and 
waiting for a reply?

Kindest regards.

Mark Lawrence.





More information about the Python-list mailing list