About __init__ and default arguments

Nathan Duran cocoa at khiltd.com
Fri Apr 11 21:12:59 CEST 2008

On Apr 11, 2008, at 11:35 AM, python-list-request at python.org wrote:
> I'd like to assign the value of an attribute in __init__ as the  
> default
> value of an argument in a method.  See below:

Are you sure? You will not get fresh values with each call in Python  
as you would in other languages.

Why not just do

def franklin(self, keyword):
     if not keyword: keyword = self.default
     return "A %s in time saves nine." % (keyword)

More information about the Python-list mailing list