1
0
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:
Rahul Gopinath 2019-12-25 10:10:53 +01:00 committed by GitHub
parent 99280f57a0
commit 2f2fcf87bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

2
README.md vendored
View File

@ -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