﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33939	Change docs for transaction.on_commit to suggest functools.partial instead of lambda	Alex Morega	Alex Morega	"I've recently got bitten by a silly bug:

{{{#!python
for n in range(10):
    transaction.on_commit(lambda: do_something(n))
}}}

Of course, instead of calling `do_something(0)`, `do_something(1)` ..., it's going to call `do_something(9)` 10 times.

The docs could help by suggesting [https://docs.python.org/3/library/functools.html#functools.partial functools.partial] instead of `lambda`. The above example becomes:

{{{#!python
for n in range(10):
    transaction.on_commit(partial(do_something, n))
}}}

If this change is a good idea I can have a go at making a PR."	Cleanup/optimization	closed	Documentation	dev	Normal	fixed			Ready for checkin	1	0	0	0	0	0
