Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Antoon Pardon
Op 25-09-17 om 00:39 schreef Gregory Ewing: > Dennis Lee Bieber wrote: >> "Binding" itself tends to be Python specific terminology -- in >> that it >> is the parameter /name/ that gets bound/attached to the argument >> /object/. >> It is the same method as used in any Python "assignment" statem

Re: [Tutor] beginning to code

2017-09-25 Thread Antoon Pardon
Op 24-09-17 om 04:13 schreef Steve D'Aprano: >> and consider >> that something else has to happen as an alternative, and (2) understand >> that in Python, objects don't have names, they have references (which >> have names). The rest could be "implementation dependent" (no?) > No. > > There are m

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Marko Rauhamaa
Antoon Pardon : > the semantics of an assignment depends on the language I've only seen one kind of assignment in the general-purpose programming languages I know, maybe with the exception of Prolog and Rust. So the assignment is the same everywhere, only the evaluation model varies. In classic

Re: [Tutor] beginning to code

2017-09-25 Thread Antoon Pardon
Op 22-09-17 om 15:30 schreef Steve D'Aprano: > On Fri, 22 Sep 2017 10:27 pm, Marko Rauhamaa wrote: > >> r...@zedat.fu-berlin.de (Stefan Ram): >> >>> Marko Rauhamaa writes: swap(slot_ref(locals(), "x"), slot_ref(locals(), "y")) >>> You need to be able to write the call as >>> >>> swap( x, y

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Antoon Pardon
Op 25-09-17 om 11:41 schreef Marko Rauhamaa: > Antoon Pardon : > >> the semantics of an assignment depends on the language > I've only seen one kind of assignment in the general-purpose programming > languages I know, maybe with the exception of Prolog and Rust. I disagree. In languages like Pasca

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Marko Rauhamaa
Antoon Pardon : > Op 25-09-17 om 11:41 schreef Marko Rauhamaa: >> Antoon Pardon : >> >>> the semantics of an assignment depends on the language >> I've only seen one kind of assignment in the general-purpose >> programming languages I know, maybe with the exception of Prolog and >> Rust. > > I dis

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Antoon Pardon
Op 25-09-17 om 13:32 schreef Marko Rauhamaa: > Antoon Pardon : > >> Op 25-09-17 om 11:41 schreef Marko Rauhamaa: >>> Antoon Pardon : >>> the semantics of an assignment depends on the language >>> I've only seen one kind of assignment in the general-purpose >>> programming languages I know, may

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Marko Rauhamaa
Antoon Pardon : > Op 25-09-17 om 13:32 schreef Marko Rauhamaa: >> In Python, assignment "mutates the target" as well. It's only that in >> Python, the target is always a pointer. > > Fine if you want to word it like that, the assignments in Pascal and > Python are still sufficiently different. > >

Re: [Tutor] beginning to code

2017-09-25 Thread Steve D'Aprano
On Mon, 25 Sep 2017 08:05 pm, Antoon Pardon wrote: > Pass by reference doesn't imply being able to > write a swap function. Really. Do you have a counter-example? > A swap function as possible in pascal requires two conditions. > > 1) Pass by reference > 2) Copy-over assignment. I don't know

Re: [Tutor] beginning to code

2017-09-25 Thread Antoon Pardon
Op 25-09-17 om 14:24 schreef Steve D'Aprano: > On Mon, 25 Sep 2017 08:05 pm, Antoon Pardon wrote: > >> Pass by reference doesn't imply being able to >> write a swap function. > Really. Do you have a counter-example? Python, smalltalk, scheme. > > >> A swap function as possible in pascal requires

Re: [Tutor] beginning to code

2017-09-25 Thread Ned Batchelder
On 9/25/17 8:24 AM, Steve D'Aprano wrote: On Mon, 25 Sep 2017 08:05 pm, Antoon Pardon wrote: Pass by reference doesn't imply being able to write a swap function. Really. Do you have a counter-example? A swap function as possible in pascal requires two conditions. 1) Pass by reference 2) Co

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Antoon Pardon
Op 25-09-17 om 14:16 schreef Marko Rauhamaa: > Antoon Pardon : > >> Op 25-09-17 om 13:32 schreef Marko Rauhamaa: >>> In Python, assignment "mutates the target" as well. It's only that in >>> Python, the target is always a pointer. >> Fine if you want to word it like that, the assignments in Pascal

Looking for an algorithm - calculate ingredients for a set of recipes

2017-09-25 Thread Paul Moore
I'm trying to work out a good algorithm to code a calculation I need to do. I can see brute force ways of handling the problem, but I keep getting bogged down in details, and the question seems like it's something that should have been solved plenty of times in the past, I just don't know where to

Re: [Tutor] beginning to code

2017-09-25 Thread Antoon Pardon
Op 25-09-17 om 14:53 schreef Ned Batchelder: > On 9/25/17 8:24 AM, Steve D'Aprano wrote: >> On Mon, 25 Sep 2017 08:05 pm, Antoon Pardon wrote: >> >>> Pass by reference doesn't imply being able to >>> write a swap function. >> Really. Do you have a counter-example? >> >> >>> A swap function as possi

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Marko Rauhamaa
Antoon Pardon : > Op 25-09-17 om 14:16 schreef Marko Rauhamaa: >> Python only operates with pointers. You can operate with pointers in >> Pascal as well. > > You are talking about implementation details. No, I'm not. I'm talking about pointers in the abstract sense, both in case of Python and Pas

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Antoon Pardon
Op 25-09-17 om 15:16 schreef Marko Rauhamaa: > Antoon Pardon : > >> Op 25-09-17 om 14:16 schreef Marko Rauhamaa: >>> Python only operates with pointers. You can operate with pointers in >>> Pascal as well. >> You are talking about implementation details. > No, I'm not. I'm talking about pointers in

Re: Looking for an algorithm - calculate ingredients for a set of recipes

2017-09-25 Thread Ian Kelly
On Mon, Sep 25, 2017 at 6:49 AM, Paul Moore wrote: > I'm trying to work out a good algorithm to code a calculation I need > to do. I can see brute force ways of handling the problem, but I keep > getting bogged down in details, and the question seems like it's > something that should have been sol

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Chris Angelico
On Mon, Sep 25, 2017 at 7:41 PM, Marko Rauhamaa wrote: > Antoon Pardon : > >> the semantics of an assignment depends on the language > > I've only seen one kind of assignment in the general-purpose programming > languages I know, maybe with the exception of Prolog and Rust. > > So the assignment i

Re: Looking for an algorithm - calculate ingredients for a set of recipes

2017-09-25 Thread Paul Moore
On 25 September 2017 at 14:23, Ian Kelly wrote: > You have a DAG, so you can sort it topologically. Then you can process > it in that order so that everything that uses X will be processed > before X so that when you get to X you'll know exactly how much of it > you need and you don't have to worr

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Marko Rauhamaa
Chris Angelico : > On Mon, Sep 25, 2017 at 7:41 PM, Marko Rauhamaa wrote: >> In Python, all expressions evaluate pointers. > > And that's an assertion that isn't backed by anything in the Python > specification. Where do you get that all Python expressions are > pointers? That's not what I said.

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Marko Rauhamaa
Antoon Pardon : > Op 25-09-17 om 15:16 schreef Marko Rauhamaa: >> No, I'm not. I'm talking about pointers in the abstract sense, both in >> case of Python and Pascal. Neither language gives any hint as to the >> physical nature of the pointer. > > Yes you are. Python doesn't have pointers at the l

Re: _sitebuiltins?

2017-09-25 Thread Steve D'Aprano
On Mon, 25 Sep 2017 11:39 am, Stefan Ram wrote: > The problem with »__module__« is that it is not always > a permissible prefix for a use of the name. For example, That's not what __module__ is intended for. Just because an object obj was created inside module M doesn't mean it is accessibl

Re: _sitebuiltins?

2017-09-25 Thread Steve D'Aprano
On Mon, 25 Sep 2017 12:05 pm, Stefan Ram wrote: > So when after > > import builtins > > the expression > > builtins.dir > > yields a value, then »dir« must be in »builtins«. dir is in builtins *now*, but that doesn't tell you where it came from. Anything can be added, or removed, from bu

Re: Looking for an algorithm - calculate ingredients for a set of recipes

2017-09-25 Thread Paul Moore
On 25 September 2017 at 15:20, Paul Moore wrote: > On 25 September 2017 at 14:23, Ian Kelly wrote: >> You have a DAG, so you can sort it topologically. Then you can process >> it in that order so that everything that uses X will be processed >> before X so that when you get to X you'll know exact

Re: python console menu level looping

2017-09-25 Thread ROGER GRAYDON CHRISTMAN
On Mon, Sep 24, 2017 09:41 PM, Daiyue Weng wrote: > Hi, I tried to make a menu using print statements in Python 3. The code is >as follows, > >print('insert data into: ') >data_insert_method = ['new collection', 'existing collection'] >for index, elem in enumerate(data_insert_method): >print(ind

Re: [Tutor] beginning to code

2017-09-25 Thread Ned Batchelder
On 9/25/17 9:15 AM, Antoon Pardon wrote: Op 25-09-17 om 14:53 schreef Ned Batchelder: On 9/25/17 8:24 AM, Steve D'Aprano wrote: On Mon, 25 Sep 2017 08:05 pm, Antoon Pardon wrote: Pass by reference doesn't imply being able to write a swap function. Really. Do you have a counter-example? A

Grumpy-pants spoil-sport [was Re: [Tutor] beginning to code]

2017-09-25 Thread Steve D'Aprano
On Mon, 25 Sep 2017 10:53 pm, Ned Batchelder wrote: > Would we be able to end these interminable debates if we just agree that > we all know how it works, If only that were true. Not everyone understands Python semantics (or for that matter, Java/Swift/language of your choice) and I still come a

TypeError with map with no len()

2017-09-25 Thread john polo
Python List, I am trying to make practice data for plotting purposes. I am using Python 3.6. The instructions I have are import matplotlib.pyplot as plt import math import numpy as np t = np.arange(0, 2.5, 0.1) y1 = map(math.sin, math.pi*t) plt.plot(t,y1) However, at this point, I get a TypeE

Re: Grumpy-pants spoil-sport [was Re: [Tutor] beginning to code]

2017-09-25 Thread Ned Batchelder
On 9/25/17 12:29 PM, Steve D'Aprano wrote: Regardless of whether I'm using Python, Swift, Java, C, Pascal or Scheme, if I write something like: x = Parrot(name="Polly") (using Python syntax for simplicity) and somebody tries to tell me that the value of x is anything but a Parrot instance named

calling __del__ [was Re: [Tutor] beginning to code]

2017-09-25 Thread Steve D'Aprano
On Sun, 24 Sep 2017 09:13 am, Bill wrote: [context snipped for brevity] > I agree (I was a bit hasty in my choice of words); but if they didn't > "have" these references, it would be difficult, though not impossible, > to refer to them. Also keep in mind that the garbage collector keeps > track,

Re: TypeError with map with no len()

2017-09-25 Thread Terry Reedy
On 9/25/2017 12:44 PM, john polo wrote: Python List, I am trying to make practice data for plotting purposes. I am using Python 3.6. The instructions I have are import matplotlib.pyplot as plt import math import numpy as np t = np.arange(0, 2.5, 0.1) y1 = map(math.sin, math.pi*t) Change to

Re: Grumpy-pants spoil-sport [was Re: [Tutor] beginning to code]

2017-09-25 Thread Tim Chase
On 2017-09-26 02:29, Steve D'Aprano wrote: > x = Parrot(name="Polly") > > (using Python syntax for simplicity) and somebody tries to tell me > that the value of x is anything but a Parrot instance named "Polly", So this is a Polly-morphic constructor? -tkc -- https://mail.python.org/mailman/l

Re: TypeError with map with no len()

2017-09-25 Thread Ned Batchelder
On 9/25/17 12:44 PM, john polo wrote: Python List, I am trying to make practice data for plotting purposes. I am using Python 3.6. The instructions I have are import matplotlib.pyplot as plt import math import numpy as np t = np.arange(0, 2.5, 0.1) y1 = map(math.sin, math.pi*t) plt.plot(t,y1)

Re: TypeError with map with no len()

2017-09-25 Thread Peter Otten
john polo wrote: > Python List, > > I am trying to make practice data for plotting purposes. I am using > Python 3.6. The instructions I have are > > import matplotlib.pyplot as plt > import math > import numpy as np > t = np.arange(0, 2.5, 0.1) > y1 = map(math.sin, math.pi*t) > plt.plot(t,y1) >

Re: TypeError with map with no len()

2017-09-25 Thread Grant Edwards
On 2017-09-25, john polo wrote: > Python List, > > I am trying to make practice data for plotting purposes. I am using > Python 3.6. The instructions I have are > > import matplotlib.pyplot as plt > import math > import numpy as np > t = np.arange(0, 2.5, 0.1) > y1 = map(math.sin, math.pi*t) > pl

Re: TypeError with map with no len()

2017-09-25 Thread Paul Moore
You're using Python 3, and I suspect that you're working from instructions that assume Python 2. In Python 3, the result of map() is a generator, not a list (which is what Python 2's map returned). In order to get an actual list (which appears to be what you need for your plot call) you just need t

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Antoon Pardon
On 25-09-17 16:29, Marko Rauhamaa wrote: > Antoon Pardon : > >> Op 25-09-17 om 15:16 schreef Marko Rauhamaa: >>> No, I'm not. I'm talking about pointers in the abstract sense, both in >>> case of Python and Pascal. Neither language gives any hint as to the >>> physical nature of the pointer. >> >>

Re: [Tutor] beginning to code

2017-09-25 Thread Antoon Pardon
On 25-09-17 15:37, Ned Batchelder wrote: > On 9/25/17 9:15 AM, Antoon Pardon wrote: >> Op 25-09-17 om 14:53 schreef Ned Batchelder: >>> On 9/25/17 8:24 AM, Steve D'Aprano wrote: On Mon, 25 Sep 2017 08:05 pm, Antoon Pardon wrote: > Pass by reference doesn't imply being able to > wr

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Chris Angelico
On Tue, Sep 26, 2017 at 3:04 AM, Antoon Pardon wrote: > On 25-09-17 16:29, Marko Rauhamaa wrote: >> Antoon Pardon : >> >>> Op 25-09-17 om 15:16 schreef Marko Rauhamaa: No, I'm not. I'm talking about pointers in the abstract sense, both in case of Python and Pascal. Neither language gives

Re: Grumpy-pants spoil-sport [was Re: [Tutor] beginning to code]

2017-09-25 Thread Chris Angelico
On Tue, Sep 26, 2017 at 2:52 AM, Tim Chase wrote: > On 2017-09-26 02:29, Steve D'Aprano wrote: >> x = Parrot(name="Polly") >> >> (using Python syntax for simplicity) and somebody tries to tell me >> that the value of x is anything but a Parrot instance named "Polly", > > So this is a Polly-morphic

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Chris Angelico
On Tue, Sep 26, 2017 at 12:26 AM, Marko Rauhamaa wrote: > Chris Angelico : > >> On Mon, Sep 25, 2017 at 7:41 PM, Marko Rauhamaa wrote: >>> In Python, all expressions evaluate pointers. >> >> And that's an assertion that isn't backed by anything in the Python >> specification. Where do you get tha

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Antoon Pardon
On 25-09-17 19:31, Chris Angelico wrote: > On Tue, Sep 26, 2017 at 3:04 AM, Antoon Pardon > wrote: >> On 25-09-17 16:29, Marko Rauhamaa wrote: >>> Antoon Pardon : >>> Op 25-09-17 om 15:16 schreef Marko Rauhamaa: > No, I'm not. I'm talking about pointers in the abstract sense, both in

Re: TypeError with map with no len()

2017-09-25 Thread john polo
On 9/25/2017 12:03 PM, Paul Moore wrote: You're using Python 3, and I suspect that you're working from instructions that assume Python 2. In Python 3, the result of map() is a generator, not a list (which is what Python 2's map returned). In order to get an actual list (which appears to be what y

Re: Call by binding [was re: [Tutor] beginning to code]

2017-09-25 Thread ROGER GRAYDON CHRISTMAN
I would claim that these two paragraphs do not agree. What is stored in the variable in Pascal? In declared variables and value parameters, the value itself. Let's just temporarily stipulate that for reference parameters and pointer variables actually store a pointer to the object. Where is it r

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Chris Angelico
On Tue, Sep 26, 2017 at 3:54 AM, Antoon Pardon wrote: > On 25-09-17 19:31, Chris Angelico wrote: >> If by "identity" you mean the integer values returned by id(), then >> nope, you're still wrong - there is no mapping from identities to >> values. There is a mapping from name to object/value, and

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Rhodri James
On 25/09/17 15:26, Marko Rauhamaa wrote: Chris Angelico : On Mon, Sep 25, 2017 at 7:41 PM, Marko Rauhamaa wrote: In Python, all expressions evaluate pointers. And that's an assertion that isn't backed by anything in the Python specification. Where do you get that all Python expressions are

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Antoon Pardon
On 25-09-17 20:01, Chris Angelico wrote: > On Tue, Sep 26, 2017 at 3:54 AM, Antoon Pardon > wrote: >> On 25-09-17 19:31, Chris Angelico wrote: >>> If by "identity" you mean the integer values returned by id(), then >>> nope, you're still wrong - there is no mapping from identities to >>> values. T

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Chris Angelico
On Tue, Sep 26, 2017 at 4:30 AM, Antoon Pardon wrote: > On 25-09-17 20:01, Chris Angelico wrote: >> On Tue, Sep 26, 2017 at 3:54 AM, Antoon Pardon >> wrote: >>> On 25-09-17 19:31, Chris Angelico wrote: If by "identity" you mean the integer values returned by id(), then nope, you're stil

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Marko Rauhamaa
Chris Angelico : > On Tue, Sep 26, 2017 at 12:26 AM, Marko Rauhamaa wrote: > Sorry, that was my bad in the terminology. But where do you get that > all Python expressions evaluate to pointers? What do they evaluate to if not pointers? Anton's "identities" would work, too. "Address" would do, as

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Marko Rauhamaa
Chris Angelico : > You need *some* support for your assertion that there are pointers, What would convince you? Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: [Tutor] beginning to code

2017-09-25 Thread Ned Batchelder
On 9/25/17 5:32 AM, Antoon Pardon wrote: Can you explain, what you mean by "Pass-By-Reference" as far a I understand, pass by reference means that the parameter of the function becomes an alias of the argument, so that if the entity is mutated through one name that mutation is visible through the

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Chris Angelico
On Tue, Sep 26, 2017 at 5:35 AM, Marko Rauhamaa wrote: > Chris Angelico : > >> On Tue, Sep 26, 2017 at 12:26 AM, Marko Rauhamaa wrote: >> Sorry, that was my bad in the terminology. But where do you get that >> all Python expressions evaluate to pointers? > > What do they evaluate to if not pointe

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Marko Rauhamaa
Rhodri James : > On 25/09/17 15:26, Marko Rauhamaa wrote: >> That's not what I said. I said all expressions *evaluate to* pointers. > > This may well be true in particular implementations, but it is an > implementation detail so Chris' point still stands. Another > implementation could evaluate ex

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Chris Angelico
On Tue, Sep 26, 2017 at 5:36 AM, Marko Rauhamaa wrote: > Chris Angelico : >> You need *some* support for your assertion that there are pointers, > > What would convince you? Evidence, or a statement from the documentation. ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Tim Golden
On 25/09/2017 20:40, Marko Rauhamaa wrote: Rhodri James : On 25/09/17 15:26, Marko Rauhamaa wrote: That's not what I said. I said all expressions *evaluate to* pointers. This may well be true in particular implementations, but it is an implementation detail so Chris' point still stands. Anot

Re: [Tutor] beginning to code

2017-09-25 Thread Chris Angelico
On Tue, Sep 26, 2017 at 5:51 AM, Stefan Ram wrote: > Ned Batchelder writes: >>Wikipedia has the right definition of call by reference > > Assertions can be right or wrong. > > Definitions cannot be right or wrong. You have made two assertions. One of them is right. The other is wrong. :-) C

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Marko Rauhamaa
Chris Angelico : > On Tue, Sep 26, 2017 at 5:36 AM, Marko Rauhamaa wrote: >> Chris Angelico : >>> You need *some* support for your assertion that there are pointers, >> >> What would convince you? > > Evidence, or a statement from the documentation. I mean, what piece of Python code could decide

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Neil Cerutti
On 2017-09-25, Steve D'Aprano wrote: > So I believe that either "call by binding" or "call by > assignment" could both equally apply to any and all languages > with function parameters, regardless of implementation or the > language's defined semantics. I disagree on C++ where there's a keen diff

Re: [Tutor] beginning to code

2017-09-25 Thread Antoon Pardon
On 25-09-17 21:44, Ned Batchelder wrote: > On 9/25/17 5:32 AM, Antoon Pardon wrote: >> Can you explain, what you mean by "Pass-By-Reference" as far a I understand, >> pass by reference means that the parameter of the function becomes an alias >> of the argument, so that if the entity is mutated thr

Re: Grumpy-pants spoil-sport [was Re: [Tutor] beginning to code]

2017-09-25 Thread Antoon Pardon
On 25-09-17 18:29, Steve D'Aprano wrote: > > Regardless of whether I'm using Python, Swift, Java, C, Pascal or Scheme, if I > write something like: > > x = Parrot(name="Polly") > > (using Python syntax for simplicity) and somebody tries to tell me that the > value of x is anything but a Parrot

Re: problems with Methods in Python 3.4.2

2017-09-25 Thread claudemirxavier49
Traceback (most recent call last): File "", line 1, in nome = input("Digite seu nome:") File "", line 1, in NameError: name 'rick' is not defined >>> Estou com esse problema alguem me ajuda pfvr -- https://mail.python.org/mailman/listinfo/python-list

Re: Grumpy-pants spoil-sport [was Re: [Tutor] beginning to code]

2017-09-25 Thread Gregory Ewing
Steve D'Aprano wrote: Or perhaps I should say: I disintegrate it really snooze to pyramid running when the ribbons they apply to sandwiches are not the same as the sleep I use. You could say that, and nobody would care much. If you insisted that your personal interpretation of those

Re: Calling methods without objects?

2017-09-25 Thread Chris Angelico
On Tue, Sep 26, 2017 at 8:49 AM, Stefan Ram wrote: > |>>> from random import randint > | > |>>> randint > |> > | > |>>> randint.__self__ > | > | > |>>> randint( 2, 3 ) > |2 > > It seems I am calling the method »randint« of the object at > »0x389798«, but I do not have to write the object into

Re: Calling methods without objects?

2017-09-25 Thread Thomas Jollans
On 26/09/17 00:49, Stefan Ram wrote: > |>>> from random import randint > | > |>>> randint > |> > | > |>>> randint.__self__ > | > | > |>>> randint( 2, 3 ) > |2 > > It seems I am calling the method »randint« of the object at > »0x389798«, but I do not have to write the object into the > call!?

Re: TypeError with map with no len()

2017-09-25 Thread Thomas Jollans
On 25/09/17 18:44, john polo wrote: > Python List, > > I am trying to make practice data for plotting purposes. I am using > Python 3.6. The instructions I have are > > import matplotlib.pyplot as plt > import math > import numpy as np > t = np.arange(0, 2.5, 0.1) > y1 = map(math.sin, math.pi*t) I

Re: Calling methods without objects?

2017-09-25 Thread Thomas Jollans
On 26/09/17 01:04, Thomas Jollans wrote: > > In [1]: class C: > >...: def m(self): > >...: return True I'll have to give my MUA a stern talking to about the importance of whitespace. Anyway, you know what I mean. > >...: -- https://mail.python.org/mailman/listinfo/python-list

Re: problems with Methods in Python 3.4.2

2017-09-25 Thread MRAB
On 2017-09-25 23:17, claudemirxavie...@gmail.com wrote: Traceback (most recent call last): File "", line 1, in nome = input("Digite seu nome:") File "", line 1, in NameError: name 'rick' is not defined Estou com esse problema alguem me ajuda pfvr It looks like what you would get

Printing a Chunk Of Words

2017-09-25 Thread Cai Gengyang
""" Boolean Operators True and True is True True and False is False False and True is False False and False is False True or True is True True or False is True False or True is True False or False is False Not True is False Not False is True """ If I simply w

Re: Printing a Chunk Of Words

2017-09-25 Thread Chris Angelico
On Tue, Sep 26, 2017 at 10:15 AM, Cai Gengyang wrote: > """ > Boolean Operators > > True and True is True > True and False is False > False and True is False > False and False is False > > True or True is True > True or False is True > False or True is True > False or

Re: Printing a Chunk Of Words

2017-09-25 Thread Rick Johnson
On Monday, September 25, 2017 at 7:15:41 PM UTC-5, Cai Gengyang wrote: > """ > Boolean Operators > > True and True is True > True and False is False > False and True is False > False and False is False > > True or True is True > True or False is True > False or

Running a GUI program haults the calling program (linux)

2017-09-25 Thread Kryptxy via Python-list
I want to run a GUI program (transmission-gtk) from python. This is what I do: import subprocess subprocess.Popen(['transmission-gtk', link], stdout=subprocess.PIPE, stderr=subprocess.PIPE) Where `link` is some magnetic link. This command opens transmission-gtk, but it haults the calling progra

Re: Running a GUI program haults the calling program (linux)

2017-09-25 Thread Chris Angelico
On Tue, Sep 26, 2017 at 10:38 AM, Kryptxy via Python-list wrote: > I want to run a GUI program (transmission-gtk) from python. This is what I do: > > import subprocess > subprocess.Popen(['transmission-gtk', link], stdout=subprocess.PIPE, > stderr=subprocess.PIPE) > > Where `link` is some magneti

Reductionism gone mad [was Re: Call by binding]

2017-09-25 Thread Steve D'Aprano
On Tue, 26 Sep 2017 05:35 am, Marko Rauhamaa wrote: > Chris Angelico : > >> On Tue, Sep 26, 2017 at 12:26 AM, Marko Rauhamaa wrote: >> Sorry, that was my bad in the terminology. But where do you get that >> all Python expressions evaluate to pointers? > > What do they evaluate to if not pointer

Re: Calling methods without objects?

2017-09-25 Thread Steve D'Aprano
On Tue, 26 Sep 2017 08:49 am, Stefan Ram wrote: > So, is there some mechanism in Python that can bind a method > to an object so that the caller does not have to specify the > object in the call? Indeed there is. Methods (like functions) are first-class values in Python, so you can do: py

Re: Printing a Chunk Of Words

2017-09-25 Thread Steve D'Aprano
On Tue, 26 Sep 2017 10:15 am, Cai Gengyang wrote: > """ [snip text] > """ > > If I simply want to print a chunk of words and a paragraph like the above, > what command should I use ? Print to the terminal? Use print(). Print to an actual printer? There's no built-in command in Python to do so,

Re: Grumpy-pants spoil-sport [was Re: [Tutor] beginning to code]

2017-09-25 Thread Steve D'Aprano
On Tue, 26 Sep 2017 02:54 am, Ned Batchelder wrote: [...] Heh, its hard to avoid getting sucked into the sinkhole of definitional debates, isn't it? :-) [...] > But in this line: > > x = 2 + 2 > > You can say, > > the value of x is 4 If we're talking about the highest level abstraction leve

Re: Printing a Chunk Of Words

2017-09-25 Thread Ben Bacarisse
r...@zedat.fu-berlin.de (Stefan Ram) writes: > Cai Gengyang writes: >> Boolean Operators >> >>True and True is True >>True and False is False >>False and True is False >>False and False is False >>True or True is True >>True or False is True >>False or True is Tr

Re: Running a GUI program haults the calling program (linux)

2017-09-25 Thread Michael Torrie
On 09/25/2017 06:38 PM, Kryptxy via Python-list wrote: > Is there any way that the GUI program is opened, and immediately the > control returns to calling program, instead of keeping the terminal > busy? Yes. This is a classic situation where you want to first fork() the process, then exec() the n

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Bill
Chris Angelico wrote: On Tue, Sep 26, 2017 at 5:35 AM, Marko Rauhamaa wrote: Chris Angelico : On Tue, Sep 26, 2017 at 12:26 AM, Marko Rauhamaa wrote: Sorry, that was my bad in the terminology. But where do you get that all Python expressions evaluate to pointers? What do they evaluate to if

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Bill
Tim Golden wrote: On 25/09/2017 20:40, Marko Rauhamaa wrote: Rhodri James : On 25/09/17 15:26, Marko Rauhamaa wrote: That's not what I said. I said all expressions *evaluate to* pointers. This may well be true in particular implementations, but it is an implementation detail so Chris' point

Re: Grumpy-pants spoil-sport [was Re: [Tutor] beginning to code]

2017-09-25 Thread Ned Batchelder
On 9/25/17 10:20 PM, Steve D'Aprano wrote: On Tue, 26 Sep 2017 02:54 am, Ned Batchelder wrote: [...] We've been asked nicely by the list mod to stop :) --Ned. -- https://mail.python.org/mailman/listinfo/python-list

PyQt: Parenting a Widget

2017-09-25 Thread Veek M
Summary: Could someone explain widget and dialog parenting - the text book is not making sense. ## I'm trying to understand widget parenting, from the book: Rapid GUI Programming, pg 118, and thereabouts - he says: A. All PyQt classes that derive from QObjectand this includes

Re: PyQt: Parenting a Widget

2017-09-25 Thread Veek M
On Tuesday, September 26, 2017 at 11:18:54 AM UTC+5:30, Veek M wrote: > Summary: Could someone explain widget and dialog parenting - the text book is > not making sense. > ## > I'm trying to understand widget parenting, from the book: Rapid GUI > Programming, pg 118, and there

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Gregory Ewing
Neil Cerutti wrote: The quest to find a succinct way to categorize Python's argument passing for non-Python programmers strikes me as a sincere effort to to simplify something that just isn't simple. I don't see how it's useful to do that in the first place. Under what circumstances would you f

Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Chris Angelico
On Tue, Sep 26, 2017 at 4:25 PM, Gregory Ewing wrote: > Neil Cerutti wrote: >> >> The quest to find a succinct way to categorize Python's argument >> passing for non-Python programmers strikes me as a sincere effort >> to to simplify something that just isn't simple. > > > I don't see how it's use

Re: [Tutor] beginning to code

2017-09-25 Thread Gregory Ewing
Antoon Pardon wrote: It also says: This typically means that the function can modify the variable used as argument, something Python can do that. No, it can't. It can modify the *object* bound to the variable, but *not* the variable itself. If you think it can, then you're misunderstanding wha

Re: Running a GUI program haults the calling program (linux)

2017-09-25 Thread Cameron Simpson
On 25Sep2017 20:59, Michael Torrie wrote: On 09/25/2017 06:38 PM, Kryptxy via Python-list wrote: Is there any way that the GUI program is opened, and immediately the control returns to calling program, instead of keeping the terminal busy? Yes. This is a classic situation where you want to fi

Re: Calling methods without objects?

2017-09-25 Thread Gregory Ewing
Thomas Jollans wrote: When an object is constructed from a class, all functions in the class are turned into method objects that refer back to the original object. That's not quite true. Nothing is done to the methods at the time an instance is created; rather, a bound method object is created