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

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

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

Re: Classes and functions.

2008-09-26 Thread Terry Reedy
aditya shukla wrote: Hello folks , i am using the newick module http://www.daimi.au.dk/~mailund/newick.html.I am just learning to use it and i have a question about it. from newick.tree import parse_tree from newick.tree import add_parent_links from newick.tree import add_distance_from_root

Classes and functions.

2008-09-26 Thread aditya shukla
Hello folks , i am using the newick module http://www.daimi.au.dk/~mailund/newick.html.I am just learning to use it and i have a question about it. from newick.tree import parse_tree from newick.tree import add_parent_links from newick.tree import add_distance_from_root import sys t = parse_t

Re: classes and functions

2007-03-05 Thread Gabriel Genellina
En Sat, 03 Mar 2007 17:04:33 -0300, Arnaud Delobelle <[EMAIL PROTECTED]> escribió: > On Mar 2, 11:01 pm, Nicholas Parsons <[EMAIL PROTECTED]> > wrote: >> That is the beauty of using Python. You have a choice of using >> classes and traditional OOP techniques or sticking to top level >> function

Re: classes and functions

2007-03-03 Thread Arnaud Delobelle
On Mar 2, 11:01 pm, Nicholas Parsons <[EMAIL PROTECTED]> wrote: > Hi Claire, > > That is the beauty of using Python. You have a choice of using > classes and traditional OOP techniques or sticking to top level > functions. For short, small scripts it would probably be overkill to > use clas

Re: classes and functions

2007-03-03 Thread James Stroud
Silver Rock wrote: > Friends, > > I don´t see why using classes.. functions does everything already. I > read the Rossum tutotial and two other already. > > Maybe this is because I am only writing small scripts, or some more > serious misunderstandings of the language. > > Please give me a light

Re: classes and functions

2007-03-02 Thread Thomas Dybdahl Ahle
Den Fri, 02 Mar 2007 19:26:08 -0300 skrev Silver Rock: > Friends, > > I don´t see why using classes.. functions does everything already. I > read the Rossum tutotial and two other already. > > Maybe this is because I am only writing small scripts, or some more > serious misunderstandings of the

Re: classes and functions

2007-03-02 Thread Nicholas Parsons
Hi Claire, That is the beauty of using Python. You have a choice of using classes and traditional OOP techniques or sticking to top level functions. For short, small scripts it would probably be overkill to use classes. Yet the programmer still has classes in his tool chest if he/she is

Re: classes and functions

2007-03-02 Thread Bruno Desthuilliers
Silver Rock a écrit : > Friends, > > I don´t see why using classes.. functions does everything already. I > read the Rossum tutotial and two other already. > > Maybe this is because I am only writing small scripts, or some more > serious misunderstandings of the language. or both ?-) If you onl

classes and functions

2007-03-02 Thread Silver Rock
Friends, I don´t see why using classes.. functions does everything already. I read the Rossum tutotial and two other already. Maybe this is because I am only writing small scripts, or some more serious misunderstandings of the language. Please give me a light. thanks guys, Claire -- http://mai

Re: Classes and Functions - General Questions

2006-10-19 Thread Sybren Stuvel
Setash enlightened us with: >> class1.py: >> >> class Class1(object): >> pass >> >> class2.py: >> import class1 This line imports class1.py and places its contents under the name "class1". > classes.py: > > class Class1 > pass > > class Class2(Class1) > pass That's co

Re: Classes and Functions - General Questions

2006-10-19 Thread John Salerno
John Salerno wrote: > Setash wrote: > >> And have class2 inherit class1 without any import statements, or need >> it be imported first? >> Or need class1 and class2 be both declared in the same .py file if >> there is inheritance? > > If the classes are in the same module, you don't need to do an

Re: Classes and Functions - General Questions

2006-10-18 Thread Setash
Andreas, and everyone else - thank you! I do appreciate the information and the quick responses, this single post with <10 replies has significantly helped my understanding level. Thanks again! -- http://mail.python.org/mailman/listinfo/python-list

Re: Classes and Functions - General Questions

2006-10-18 Thread Andreas Hartl
Setash schrieb: > 2) Function overloading - is it possible? > > Can I have the following code, or something which acts the same in > python?: > > > def function(a, b) >do things > > def function(a, b, c) >do things only if I get a third argument Several ways. The simplest and often mo

Re: Classes and Functions - General Questions

2006-10-18 Thread John Salerno
Setash wrote: > Also, I have seen the following syntax used once before, and havent > found any documentation on it, any comments as to use, where to find > docs, etc?: > > from module import x as name > name.function() All that does is give you a method for renaming a particularly unrul

Re: Classes and Functions - General Questions

2006-10-18 Thread Bruno Desthuilliers
Setash a écrit : > I've got a tiny bit of coding background, but its not the most > extensive. > > That said, I'm trying to wrap my head around python and have a couple > questions with classes and functions. > > Two notable questions: > > 1) Classes. How d

Re: Classes and Functions - General Questions

2006-10-18 Thread John Salerno
Setash wrote: > And have class2 inherit class1 without any import statements, or need > it be imported first? > Or need class1 and class2 be both declared in the same .py file if > there is inheritance? If the classes are in the same module, you don't need to do any importing or qualification. I

Re: Classes and Functions - General Questions

2006-10-18 Thread Setash
> > > > And have class2 inherit class1 without any import statements, or need > > it be imported first? > > It needs to be imported first: > > class1.py: > > class Class1(object): > pass > > class2.py: > import class1 > > class Class2(class1.Class1): > pass > In respo

Re: Classes and Functions - General Questions

2006-10-18 Thread Sybren Stuvel
Setash enlightened us with: > 1) Classes. How do you extend classes? > > I know its as easy as: > > class classname(a) >do stuff > > > But where does the parent class need to lie? In the same file? Can > it lie in another .py file in the root directory? It doesn't matter at all, as long as 'a'

Classes and Functions - General Questions

2006-10-18 Thread Setash
I've got a tiny bit of coding background, but its not the most extensive. That said, I'm trying to wrap my head around python and have a couple questions with classes and functions. Two notable questions: 1) Classes. How do you extend classes? I know its as easy as: class classnam