mirror of
https://github.com/satwikkansal/wtfpython
synced 2024-11-22 02:54:25 +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:
parent
de113d2491
commit
16c90f9b24
2
README.md
vendored
2
README.md
vendored
@ -2241,7 +2241,7 @@ def some_func(default_arg=[]):
|
|||||||
|
|
||||||
```py
|
```py
|
||||||
def some_func(default_arg=None):
|
def some_func(default_arg=None):
|
||||||
if default_arg is not None:
|
if default_arg is None:
|
||||||
default_arg = []
|
default_arg = []
|
||||||
default_arg.append("some_string")
|
default_arg.append("some_string")
|
||||||
return default_arg
|
return default_arg
|
||||||
|
Loading…
Reference in New Issue
Block a user