[Python-checkins] Dataclasses: Fix example on 30.6.8, add method should receive a list rather than an integer. (GH-8038) (GH-8237)

Eric V. Smith webhook-mailer at python.org
Wed Jul 11 06:11:15 EDT 2018


https://github.com/python/cpython/commit/bcea15a6110737aa87147222b108281bcb41866b
commit: bcea15a6110737aa87147222b108281bcb41866b
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Eric V. Smith <ericvsmith at users.noreply.github.com>
date: 2018年07月11日T06:11:11-04:00
summary:
Dataclasses: Fix example on 30.6.8, add method should receive a list rather than an integer. (GH-8038) (GH-8237)
Change example function to append rather than add lists.
(cherry picked from commit da5e9476bbfbe61f7661fd22caba1b675e5b4397)
Co-authored-by: Tom Faulkner <tomfaulkner at gmail.com>
files:
M Doc/library/dataclasses.rst
diff --git a/Doc/library/dataclasses.rst b/Doc/library/dataclasses.rst
index 9835c480d0ea..e9af20a04af1 100644
--- a/Doc/library/dataclasses.rst
+++ b/Doc/library/dataclasses.rst
@@ -533,7 +533,7 @@ Mutable default values
 class C:
 x = []
 def add(self, element):
- self.x += element
+ self.x.append(element)
 
 o1 = C()
 o2 = C()


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /