mirror of
https://github.com/satwikkansal/wtfpython
synced 2024-11-22 11:04:25 +01:00
Make sure that default_arg is not passed rather than checking for falsity
``` if not default_arg: ... ``` fails when `default_arg` can be assigned and still be false (implementing a `__bool__` or `__len__` etc). You dont want to overwrite the passed values.
This commit is contained in:
parent
99280f57a0
commit
2f2fcf87bc
2
README.md
vendored
2
README.md
vendored
@ -2173,7 +2173,7 @@ def some_func(default_arg=[]):
|
|||||||
|
|
||||||
```py
|
```py
|
||||||
def some_func(default_arg=None):
|
def some_func(default_arg=None):
|
||||||
if not default_arg:
|
if default_arg is not 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