Commit aee5e26
committed
Add warning that mutable argument defaults are evaluated only once;
with examples and workaround. This keeps coming up, and I believe
that this section in the tutorial may have been (in part) the source
of the confusion. While it didn't show examples with [] for a default,
it also didn't emphasize enough why that would be a bad idea, and
while it did say that defaults are evaluated at the point of function
definition, the example was not relevant for this issue.1 parent 1a0b872 commit aee5e26
1 file changed
Lines changed: 39 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1186 | 1186 | | |
1187 | 1187 | | |
1188 | 1188 | | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
1189 | 1222 | | |
1190 | 1223 | | |
1191 | 1224 | | |
| |||
1574 | 1607 | | |
1575 | 1608 | | |
1576 | 1609 | | |
| 1610 | + | |
1577 | 1611 | | |
1578 | 1612 | | |
1579 | 1613 | | |
| |||
1583 | 1617 | | |
1584 | 1618 | | |
1585 | 1619 | | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
1586 | 1623 | | |
1587 | 1624 | | |
1588 | 1625 | | |
| |||
1858 | 1895 | | |
1859 | 1896 | | |
1860 | 1897 | | |
| 1898 | + | |
| 1899 | + | |
1861 | 1900 | | |
1862 | 1901 | | |
1863 | 1902 | | |
| |||
0 commit comments