1
0
mirror of https://github.com/satwikkansal/wtfpython synced 2024-11-21 18:54:20 +01:00

Fixed logic error in "Beware of default mutable arguments!"

The example showing how using None as a default argument is used
instead of a mutable default argument had reversed logic.  It would
set default_arg to [] whenever the caller passed a non-None argument.
This commit is contained in:
Lars Kellogg-Stedman 2020-01-19 12:03:30 -05:00
parent de113d2491
commit 16c90f9b24

2
README.md vendored
View File

@ -2241,7 +2241,7 @@ def some_func(default_arg=[]):
```py
def some_func(default_arg=None):
if default_arg is not None:
if default_arg is None:
default_arg = []
default_arg.append("some_string")
return default_arg