mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-11-23 06:03:07 +03:00
Merge pull request #3424 from EvilKhaosKat/patch-1
[python3/en] A note about common gotcha with mutable defaults
This commit is contained in:
commit
f03d941d86
@ -808,6 +808,7 @@ class Superhero(Human):
|
|||||||
# add additional class attributes:
|
# add additional class attributes:
|
||||||
self.fictional = True
|
self.fictional = True
|
||||||
self.movie = movie
|
self.movie = movie
|
||||||
|
# be aware of mutable default values, since defaults are shared
|
||||||
self.superpowers = superpowers
|
self.superpowers = superpowers
|
||||||
|
|
||||||
# The "super" function lets you access the parent class's methods
|
# The "super" function lets you access the parent class's methods
|
||||||
|
Loading…
Reference in New Issue
Block a user