Re: Quirk difference between classes and functions

2019-02-27 Thread Peter J. Holzer
On 2019-02-27 12:34:37 -0500, Dennis Lee Bieber wrote: > On Tue, 26 Feb 2019 19:15:16 -0800 (PST), jf...@ms4.hinet.net declaimed the > following: > > >So, may I say that the Python compiler is a multi-pass one? > > No... that is implementation dependent... True, but > The common Pyt

Re: Quirk difference between classes and functions

2019-02-27 Thread jfong
jf...@ms4.hinet.net於 2019年2月26日星期二 UTC+8下午4時46分04秒寫道: > ast於 2019年2月26日星期二 UTC+8上午12時25分40秒寫道: > > Hello > > > > I noticed a quirk difference between classes and functions > > > > >>> x=0 > > >>> > > >>> cla

Re: Quirk difference between classes and functions

2019-02-26 Thread jfong
Chris Angelico於 2019年2月27日星期三 UTC+8上午11時29分04秒寫道: > On Wed, Feb 27, 2019 at 2:21 PM wrote: > > > > Chris Angelico於 2019年2月27日星期三 UTC+8上午9時25分11秒寫道: > > > On Wed, Feb 27, 2019 at 12:21 PM wrote: > > > > > > > > Gregory Ewing at 2019/2/27 AM 5:26:49 wrote: > > > > > Thomas Jollans wrote: > > > > >

Re: Quirk difference between classes and functions

2019-02-26 Thread Chris Angelico
On Wed, Feb 27, 2019 at 2:21 PM wrote: > > Chris Angelico於 2019年2月27日星期三 UTC+8上午9時25分11秒寫道: > > On Wed, Feb 27, 2019 at 12:21 PM wrote: > > > > > > Gregory Ewing at 2019/2/27 AM 5:26:49 wrote: > > > > Thomas Jollans wrote: > > > > > I imagine there's a justification for the difference in behaviou

Re: Quirk difference between classes and functions

2019-02-26 Thread jfong
Chris Angelico於 2019年2月27日星期三 UTC+8上午9時25分11秒寫道: > On Wed, Feb 27, 2019 at 12:21 PM wrote: > > > > Gregory Ewing at 2019/2/27 AM 5:26:49 wrote: > > > Thomas Jollans wrote: > > > > I imagine there's a justification for the difference in behaviour to do > > > > with the fact that the body of a class

Re: Quirk difference between classes and functions

2019-02-26 Thread Chris Angelico
On Wed, Feb 27, 2019 at 12:21 PM wrote: > > Gregory Ewing at 2019/2/27 AM 5:26:49 wrote: > > Thomas Jollans wrote: > > > I imagine there's a justification for the difference in behaviour to do > > > with the fact that the body of a class is only ever executed once, while > > > the body of a functi

Re: Quirk difference between classes and functions

2019-02-26 Thread eryk sun
On 2/26/19, Gregory Ewing wrote: > Thomas Jollans wrote: >> I imagine there's a justification for the difference in behaviour to do >> with the fact that the body of a class is only ever executed once, while >> the body of a function is executed multiple times. > > I suspect there isn't any deep r

Re: Quirk difference between classes and functions

2019-02-26 Thread jfong
Gregory Ewing at 2019/2/27 AM 5:26:49 wrote: > Thomas Jollans wrote: > > I imagine there's a justification for the difference in behaviour to do > > with the fact that the body of a class is only ever executed once, while > > the body of a function is executed multiple times. > > I suspect there i

RE: Quirk difference between classes and functions

2019-02-26 Thread Steve
#x27;s 117 bugs in the code. -Original Message- From: Python-list On Behalf Of Gregory Ewing Sent: Tuesday, February 26, 2019 4:27 PM To: python-list@python.org Subject: Re: Quirk difference between classes and functions Thomas Jollans wrote: > I imagine there's a justification for

Re: Quirk difference between classes and functions

2019-02-26 Thread Gregory Ewing
Thomas Jollans wrote: I imagine there's a justification for the difference in behaviour to do with the fact that the body of a class is only ever executed once, while the body of a function is executed multiple times. I suspect there isn't any deep reason for it, rather it's just something that

Re: Quirk difference between classes and functions

2019-02-26 Thread Thomas Jollans
On 25/02/2019 21.15, Chris Angelico wrote: > On Tue, Feb 26, 2019 at 6:58 AM DL Neil > wrote: >> >> On 26/02/19 5:25 AM, ast wrote: >>> I noticed a quirk difference between classes and functions >>> >>> x=0 >>> >>> class Test:

Re: Quirk difference between classes and functions

2019-02-26 Thread jfong
ast於 2019年2月26日星期二 UTC+8上午12時25分40秒寫道: > Hello > > I noticed a quirk difference between classes and functions > > >>> x=0 > >>> > >>> class Test: > x = x+1 > print(x) > x = x+1 > print(x) >

Re: Quirk difference between classes and functions

2019-02-25 Thread Chris Angelico
On Tue, Feb 26, 2019 at 5:06 PM Gregory Ewing wrote: > > Chris Angelico wrote: > > Classes and functions behave differently. Inside a function, a name is > > local if it's ever assigned to; but in a class, this is not the case. > > Actually, it is. Assigning to a name in a class body makes it part

Re: Quirk difference between classes and functions

2019-02-25 Thread Gregory Ewing
Chris Angelico wrote: Classes and functions behave differently. Inside a function, a name is local if it's ever assigned to; but in a class, this is not the case. Actually, it is. Assigning to a name in a class body makes it part of the class namespace, which is the local namespace at the time

Re: Quirk difference between classes and functions

2019-02-25 Thread Chris Angelico
On Tue, Feb 26, 2019 at 6:58 AM DL Neil wrote: > > On 26/02/19 5:25 AM, ast wrote: > > I noticed a quirk difference between classes and functions > > >>> x=0 > > >>> class Test: > > x = x+1 > > print(x) > >

Re: Quirk difference between classes and functions

2019-02-25 Thread DL Neil
On 26/02/19 5:25 AM, ast wrote: I noticed a quirk difference between classes and functions >>> x=0 >>> class Test:     x = x+1     print(x)     x = x+1     print(x) ... Previous code doesn't generate any errors. x at the right of = in first "

Quirk difference between classes and functions

2019-02-25 Thread ast
Hello I noticed a quirk difference between classes and functions >>> x=0 >>> >>> class Test: x = x+1 print(x) x = x+1 print(x) 1 2 >>> print(x) 0 Previous code doesn't generate any errors. x at the right of = in fi