Re: Questioning the effects of multiple assignment

2020-07-08 Thread DL Neil via Python-list
On 8/07/20 10:19 PM, Peter J. Holzer wrote: On 2020-07-08 12:26:06 +1200, dn via Python-list wrote: OTOH, using a tuple doesn't prevent the function from mutating mutable arguments: #!/usr/bin/python3 def f(*a): a[0]["new"] = 2 v = { "old": 1} f(v) print(v) prints «{'old': 1, 'new': 2}».

Re: Questioning the effects of multiple assignment

2020-07-08 Thread dn via Python-list
On 8/07/20 11:11 PM, o1bigtenor wrote: On Tue, Jul 7, 2020 at 2:30 AM Mike Dewhirst > wrote: Original message From: dn via Python-list mailto:python-list@python.org>> Date: 7/7/20  16:04  (GMT+10:00) To: 'Python' mailto:python-list@python

Re: Questioning the effects of multiple assignment

2020-07-08 Thread dn via Python-list
On 8/07/20 2:40 PM, Kyle Stanley wrote: A matter of style, which I like to follow [is it TDD's influence? - or does it actually come-from reading about DBC (Design by Contract*)?] is the injunction that one *not* vary the value of a parameter inside a method/function. (useful

Re: Questioning the effects of multiple assignment

2020-07-08 Thread o1bigtenor
On Tue, Jul 7, 2020 at 2:30 AM Mike Dewhirst wrote: > > Original message From: dn via Python-list < > python-list@python.org> Date: 7/7/20 16:04 (GMT+10:00) To: 'Python' < > python-list@python.org> Subject: Questioning the effects of multiple > assignment TLDR; if you are a Pyt

Re: Questioning the effects of multiple assignment

2020-07-08 Thread Peter J. Holzer
On 2020-07-08 12:26:06 +1200, dn via Python-list wrote: > A matter of style, which I like to follow [is it TDD's influence? - or > does it actually come-from reading about DBC (Design by Contract*)?] I think Design by Contract only affects the interfaces (parameters, return values and side effects

Re: Questioning the effects of multiple assignment

2020-07-07 Thread Kyle Stanley
> > A matter of style, which I like to follow [is it TDD's influence? - or > does it actually come-from reading about DBC (Design by Contract*)?] is > the injunction that one *not* vary the value of a parameter inside a > method/function. > (useful in 'open-box testing' to check both the API and th

Re: Questioning the effects of multiple assignment

2020-07-07 Thread dn via Python-list
On 7/07/20 7:44 PM, Kyle Stanley wrote: Can you explain why these two (apparently) logical assignment processes have been designed to realise different result-objects? The reason is because of the conventions chosen in PEP 3132, which implemented the feature in the first place. It wa

Re: Questioning the effects of multiple assignment

2020-07-07 Thread dn via Python-list
On 7/07/20 7:21 PM, Mike Dewhirst wrote: Original message For comparison, here's the original form:- >>> def f( a, *b, c=0 ): ... print( a, type( a ) ) ... print( c, type( c ) ) ... print( b ) ... >>> f( 1, 'two', 3, 'four' ) 1 0 ('two', 3, 'four') Shouldn't

Re: Questioning the effects of multiple assignment

2020-07-07 Thread Kyle Stanley
> > Can you explain why these two (apparently) logical assignment processes > have been designed to realise different result-objects? The reason is because of the conventions chosen in PEP 3132, which implemented the feature in the first place. It was considered to return a tuple for the consiste

RE: Questioning the effects of multiple assignment

2020-07-07 Thread Mike Dewhirst
Original message From: dn via Python-list Date: 7/7/20 16:04 (GMT+10:00) To: 'Python' Subject: Questioning the effects of multiple assignment TLDR; if you are a Python 'Master' then feel free to skim the first part (which you should know hands-down), until the excerpts fro