Function attributes: a bug?

Tj tj_scarlet at yahoo.com
Sat Mar 29 13:07:39 EST 2003


Roel Mathys <Roel.Mathys at yucom.be> wrote in message news:<b63kcr$1bv4g$1 at ID-160218.news.dfncis.de>...
> 	def make_list_accum( init = None ) :
> 		def accum( elem , init = init ) :
> 			if init is None :
> 				init = []
> 			accum.list = init
> 			accum.list.append( elem )
> 			return accum.list
> 		return accum
> 
> which does what you had in mind, I hope.

Thanks!  I should have remembered reading about this behavior of default args.

I think I'll pass this on to Paul Graham.

Tj




More information about the Python-list mailing list