Re: Need some help managing project and making it a little simple (pretty messed up code)

2017-08-16 Thread dieter
Kryptxy via Python-list writes: > ... > I am new to python. While learning python, I began a side project. Its a > command-line search program. > ... > But, I am unable to understand how I should begin structuring the project > (updating code according to OOP). If someone could have a look? Coul

Re: Proposed new syntax

2017-08-16 Thread Marko Rauhamaa
Ben Finney : > The Python list comprehension syntax does not specify control flow. I understand your point, but how do you know your statement is true? I didn't check this, but I would imagine the list comprehension: [ f(x) for x in I if c(x) ] was defined as syntactic sugar for: list(f

Re: Cross-language comparison: function map and similar

2017-08-16 Thread Pavol Lisy
On 8/16/17, Steve D'Aprano wrote: > Over in another thread, we've been talking about comprehensions and their > similarities and differences from the functional map() operation. > > Reminder: > > map(chr, [65, 66, 67, 68]) > > will return ['A', 'B', 'C']. > > My questions for those who know langua

Re: Default .py program and Edit with IDLE problem

2017-08-16 Thread dieter
"Kevi Aday (Katch22)" writes: > I installed python 3.6.2 for making running and editing programs. Later on I > installed python 2.7 > because a program that I downloaded only works with that. Later I deleted the > program. I then wanted to run a > program from cmd but it was giving me all kinds

Re: A small quiz question

2017-08-16 Thread Marko Rauhamaa
Dennis Lee Bieber : > I suppose, the two in combination imply that the calls to "f()" > occur first in left to right, but then the "**" are applied to the > returned values right to left -- rather than having the calls > performed in the exponentiation order. Yes, and parentheses, operator

Re: Cross-language comparison: function map and similar

2017-08-16 Thread Paul Rubin
Steve D'Aprano writes: > Are there language implementations which evaluate the result of map() > (or its equivalent) in some order other than the obvious left-to-right > first-to-last sequential order? Is that order guaranteed by the > language, or is it an implementation detail? Haskell just giv

Re: A question on modification of a list via a function invocation

2017-08-16 Thread Steve D'Aprano
On Thu, 17 Aug 2017 12:24 pm, Stefan Ram wrote: > Steve D'Aprano writes: >>On Thu, 17 Aug 2017 11:07 am, Stefan Ram wrote: >>>So, when an argument is actually passed, then the parameter >>>can be modified? It seems Mok-Kong Shen was writing about >>>this case. >>I would say that the argument is m

Need some help managing project and making it a little simple (pretty messed up code)

2017-08-16 Thread Kryptxy via Python-list
Hello, I am new to python. While learning python, I began a side project. Its a command-line search program. Here: https://github.com/kryptxy/torrench The project is becoming a little difficult to manage, and before it becomes more complex, I'd like to sort it out a little and make it more mana

Re: A question on modification of a list via a function invocation

2017-08-16 Thread Steve D'Aprano
On Thu, 17 Aug 2017 11:07 am, Stefan Ram wrote: > Steve D'Aprano writes: >>On Thu, 17 Aug 2017 08:29 am, Mok-Kong Shen wrote: >>>In the first case, any modification of the formal parameter >>Technically, you cannot modify the formal parameter, because the formal >>parameter is just a name unbound

Re: A question on modification of a list via a function invocation

2017-08-16 Thread Steve D'Aprano
On Thu, 17 Aug 2017 10:14 am, Ned Batchelder wrote: > the name/value data model of > Python is not some trivial detail that we could change to match some > other language: it's a fundamental part of what makes Python what it is. It is also an evaluation model which matches nearly all of the most

Re: A question on modification of a list via a function invocation

2017-08-16 Thread Mok-Kong Shen
Am 17.08.2017 um 02:14 schrieb Ned Batchelder: On Thu, Aug 17, 2017 at 8:29 AM, Mok-Kong Shen wrote: Anyway, while any new user of a programming language certainly can be expected to take good efforts to learn a lot of new stuffs, I suppose it's good for any practical programming language to m

Re: A question on modification of a list via a function invocation

2017-08-16 Thread Cameron Simpson
On 17Aug2017 02:49, Mok-Kong Shen wrote: I don't yet understand. Why (by which rule of the language reference) should "alist=[30,60,90]" mean discarding the name's reference to the [1,2,3] list? Section 7.2: Simple statements: Assignment Statements. It says: An assignment statement evaluate

Re: A question on modification of a list via a function invocation

2017-08-16 Thread Mok-Kong Shen
Am 17.08.2017 um 02:41 schrieb Steve D'Aprano: On Thu, 17 Aug 2017 08:29 am, Mok-Kong Shen wrote: I have earlier learned some other (older) programming languages. For these the formal parameters are either "by reference" or "by value". By reference and by value are not the only two convention

Re: A question on modification of a list via a function invocation

2017-08-16 Thread Ben Finney
Mok-Kong Shen writes: > I don't yet understand. Why (by which rule of the language reference) > should "alist=[30,60,90]" mean discarding the name's reference to the > [1,2,3] list? I think I understand that question, but I find it surprising. What is your expectation of the following code?

Re: A small quiz question

2017-08-16 Thread Steve D'Aprano
On Thu, 17 Aug 2017 09:12 am, Dennis Lee Bieber wrote: > I suppose, the two in combination imply that the calls to "f()" occur > first in left to right, but then the "**" are applied to the returned > values right to left -- rather than having the calls performed in the > exponentiation order. St

Re: Why is my class undefined?

2017-08-16 Thread Sayth Renshaw
On Thursday, 17 August 2017 09:03:59 UTC+10, Ian wrote: wrote: > > Morning > > > > I haven't ventured into classes much before. When trying to follow some > > examples and create my own classes in a jupyter notebook I receive an error > > that the class is undefined. > > > > So I created for pr

Re: A question on modification of a list via a function invocation

2017-08-16 Thread Ben Finney
Steve D'Aprano writes: > On Thu, 17 Aug 2017 08:29 am, Mok-Kong Shen wrote: > > > I have earlier learned some other (older) programming languages. For > > these the formal parameters are either "by reference" or "by value". > > By reference and by value are not the only two conventions. > > Perha

Re: A question on modification of a list via a function invocation

2017-08-16 Thread Mok-Kong Shen
Am 17.08.2017 um 01:58 schrieb Cameron Simpson: On 17Aug2017 01:03, Mok-Kong Shen wrote: Am 17.08.2017 um 00:39 schrieb Chris Angelico: On Thu, Aug 17, 2017 at 8:29 AM, Mok-Kong Shen wrote: Chris wrote: objects exist independently of names, and names refer to objects. If you do "x = y", you'r

Re: A question on modification of a list via a function invocation

2017-08-16 Thread Steve D'Aprano
On Thu, 17 Aug 2017 08:29 am, Mok-Kong Shen wrote: > I have earlier learned some other (older) programming languages. For > these the formal parameters are either "by reference" or "by value". By reference and by value are not the only two conventions. Perhaps if you go back to the 1950s you mig

Re: A question on modification of a list via a function invocation

2017-08-16 Thread Chris Angelico
On Thu, Aug 17, 2017 at 9:03 AM, Mok-Kong Shen wrote: > Am 17.08.2017 um 00:39 schrieb Chris Angelico: >> >> On Thu, Aug 17, 2017 at 8:29 AM, Mok-Kong Shen >> wrote: >>> >>> I have earlier learned some other (older) programming languages. For >>> these the formal parameters are either "by referen

Re: A question on modification of a list via a function invocation

2017-08-16 Thread Ned Batchelder
On Thu, Aug 17, 2017 at 8:29 AM, Mok-Kong Shen wrote: > Anyway, while > any new user of a programming language certainly can be expected to > take good efforts to learn a lot of new stuffs, I suppose it's good > for any practical programming language to minimize the cases of > surprises for those

Re: A question on modification of a list via a function invocation

2017-08-16 Thread Cameron Simpson
On 17Aug2017 01:03, Mok-Kong Shen wrote: Am 17.08.2017 um 00:39 schrieb Chris Angelico: On Thu, Aug 17, 2017 at 8:29 AM, Mok-Kong Shen wrote: Chris wrote: objects exist independently of names, and names refer to objects. If you do "x = y", you're saying "figure out which object 'y' means, and

Re: Proposed new syntax

2017-08-16 Thread Ben Finney
Steve D'Aprano writes: > On Thu, 17 Aug 2017 12:28 am, Ben Finney wrote: > > > Steve D'Aprano writes: > > > >> If he wanted declarative semantics, why didn't he argue for > >> declarative syntax like "select...where", instead of choosing > >> procedural syntax which matches the actual procedura

Re: A question on modification of a list via a function invocation

2017-08-16 Thread Ian Kelly
On Wed, Aug 16, 2017 at 5:03 PM, Stefan Ram wrote: > Chris Angelico writes: >>objects exist independently of names > > When the object »Example()« loses its name below, > it loses its existence. > > class Example(object): > ... def __init__(self): > ... print( 'initialized' ) > ..

Re: Why is my class undefined?

2017-08-16 Thread Jan Erik Moström
On 17 Aug 2017, at 0:48, Sayth Renshaw wrote: > what exactly am I doing wrong? Outdent the if-statement = jem -- https://mail.python.org/mailman/listinfo/python-list

Re: A question on modification of a list via a function invocation

2017-08-16 Thread Mok-Kong Shen
Am 17.08.2017 um 00:39 schrieb Chris Angelico: On Thu, Aug 17, 2017 at 8:29 AM, Mok-Kong Shen wrote: I have earlier learned some other (older) programming languages. For these the formal parameters are either "by reference" or "by value". In the first case, any modification of the formal parame

Re: Why is my class undefined?

2017-08-16 Thread Ian Kelly
On Wed, Aug 16, 2017 at 4:48 PM, Sayth Renshaw wrote: > Morning > > I haven't ventured into classes much before. When trying to follow some > examples and create my own classes in a jupyter notebook I receive an error > that the class is undefined. > > So I created for practise a frog class > >

Re: A question on modification of a list via a function invocation

2017-08-16 Thread Cameron Simpson
On 16Aug2017 23:06, Mok-Kong Shen wrote: Am 15.08.2017 um 20:47 schrieb Larry Hudson: [snip] === test2() code == def test2(alist): ss ─┬─> [1, 2, 3] alist ─┘ - ss ─┬─> [3, 6,

Why is my class undefined?

2017-08-16 Thread Sayth Renshaw
Morning I haven't ventured into classes much before. When trying to follow some examples and create my own classes in a jupyter notebook I receive an error that the class is undefined. So I created for practise a frog class class frog(object): def __init__(self, ftype, word):

Re: A question on modification of a list via a function invocation

2017-08-16 Thread Chris Angelico
On Thu, Aug 17, 2017 at 8:29 AM, Mok-Kong Shen wrote: > I have earlier learned some other (older) programming languages. For > these the formal parameters are either "by reference" or "by value". > In the first case, any modification of the formal parameter inside > a function affects the correspo

Re: A question on modification of a list via a function invocation

2017-08-16 Thread Mok-Kong Shen
Am 16.08.2017 um 23:20 schrieb Ned Batchelder: On 8/16/17 5:06 PM, Mok-Kong Shen wrote: Am 15.08.2017 um 20:47 schrieb Larry Hudson: [snip] === test2() code == def test2(alist): ss ─┬─> [1, 2, 3] alist ─┘ ---

Re: Request Help With Gdk.Display

2017-08-16 Thread Wildman via Python-list
On Wed, 16 Aug 2017 14:33:27 -0500, Wildman wrote: > On Wed, 16 Aug 2017 19:11:16 +0100, MRAB wrote: > >> On 2017-08-16 18:57, Wildman via Python-list wrote: >>> I am working on a program for the Linux platform that >>> reports system information. The program reports screen >>> information, numb

Default .py program and Edit with IDLE problem

2017-08-16 Thread Kevi Aday (Katch22)
Hello, I installed python 3.6.2 for making running and editing programs. Later on I installed python 2.7 because a program that I downloaded only works with that. Later I deleted the program. I then wanted to run a program from cmd but it was giving me all kinds of errors I didn’t used to get.

Re: A small quiz question

2017-08-16 Thread Ben Bacarisse
Steve D'Aprano writes: > On Wed, 16 Aug 2017 11:38 pm, Ben Bacarisse wrote: > >> r...@zedat.fu-berlin.de (Stefan Ram) writes: >> >>> I wrote my first Python quiz question! >>> >>> It goes like this: >>> >>> Can you predict (without trying it out) what the Python >>> console will output a

Re: A question on modification of a list via a function invocation

2017-08-16 Thread Ned Batchelder
On 8/16/17 5:06 PM, Mok-Kong Shen wrote: > Am 15.08.2017 um 20:47 schrieb Larry Hudson: > [snip] >>> === test2() code == >>> def test2(alist): ss ─┬─> [1, 2, 3] >>> alist ─┘ >>> - >>>

Re: A question on modification of a list via a function invocation

2017-08-16 Thread Mok-Kong Shen
Am 15.08.2017 um 20:47 schrieb Larry Hudson: [snip] === test2() code == def test2(alist): ss ─┬─> [1, 2, 3] alist ─┘ - ss ─┬─> [3, 6, 9] alist ─┘

Re: Request Help With Gdk.Display

2017-08-16 Thread Wildman via Python-list
On Wed, 16 Aug 2017 19:11:16 +0100, MRAB wrote: > On 2017-08-16 18:57, Wildman via Python-list wrote: >> I am working on a program for the Linux platform that >> reports system information. The program reports screen >> information, number of monitors, resolution of each one >> and the total reso

Re: A small quiz question

2017-08-16 Thread Marko Rauhamaa
Ian Kelly : > On Wed, Aug 16, 2017 at 6:51 AM, Dennis Lee Bieber > wrote: >>>def f(i): print(i); return i; >>> >>>f(4)**f(1)**f(2) >>> >> >> As a first guess >> >> 2 >> 1 >> 4 >> >> 4 >> >> since in many languages, exponentiation associates right to left > > I thought the same thing but f

Re: Request Help With Gdk.Display

2017-08-16 Thread MRAB
On 2017-08-16 18:57, Wildman via Python-list wrote: I am working on a program for the Linux platform that reports system information. The program reports screen information, number of monitors, resolution of each one and the total resolution. It does it using a couple of external utils, Xrandr

Re: Cross-language comparison: function map and similar

2017-08-16 Thread Terry Reedy
On 8/16/2017 10:53 AM, Steve D'Aprano wrote: Over in another thread, we've been talking about comprehensions and their similarities and differences from the functional map() operation. Reminder: map(chr, [65, 66, 67, 68]) will return ['A', 'B', 'C']. The comprehension 'while' proposal is for fu

Request Help With Gdk.Display

2017-08-16 Thread Wildman via Python-list
I am working on a program for the Linux platform that reports system information. The program reports screen information, number of monitors, resolution of each one and the total resolution. It does it using a couple of external utils, Xrandr and Xdpyinfo. It is my goal to replace the existing c

Re: A small quiz question

2017-08-16 Thread Ian Kelly
On Wed, Aug 16, 2017 at 6:51 AM, Dennis Lee Bieber wrote: > On 16 Aug 2017 11:06:26 GMT, r...@zedat.fu-berlin.de (Stefan Ram) declaimed > the following: > >> I wrote my first Python quiz question! >> >> It goes like this: >> >> Can you predict (without trying it out) what the Python >> console

Re: Cross-language comparison: function map and similar

2017-08-16 Thread Rustom Mody
On Wednesday, August 16, 2017 at 8:24:46 PM UTC+5:30, Steve D'Aprano wrote: > Over in another thread, we've been talking about comprehensions and their > similarities and differences from the functional map() operation. > > Reminder: > > map(chr, [65, 66, 67, 68]) > > will return ['A', 'B', 'C']

Re: Proposed new syntax

2017-08-16 Thread Steve D'Aprano
On Wed, 16 Aug 2017 11:53 pm, jmp wrote: > On 08/10/2017 04:28 PM, Steve D'Aprano wrote: >> Every few years, the following syntax comes up for discussion, with some >> people saying it isn't obvious what it would do, and others disagreeing and >> saying that it is obvious. So I thought I'd do an i

Re: Cross-language comparison: function map and similar

2017-08-16 Thread Steve D'Aprano
On Thu, 17 Aug 2017 12:53 am, Steve D'Aprano wrote: > map(chr, [65, 66, 67, 68]) > > will return ['A', 'B', 'C']. Of course I meant ['A', 'B', 'C', 'D']. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org

Re: Proposed new syntax

2017-08-16 Thread Steve D'Aprano
On Thu, 17 Aug 2017 12:28 am, Ben Finney wrote: > Steve D'Aprano writes: > >> If he wanted declarative semantics, why didn't he argue for >> declarative syntax like "select...where", instead of choosing >> procedural syntax which matches the actual procedural semantics given? > > The syntax “f(

Re: A small quiz question

2017-08-16 Thread breamoreboy
On Wednesday, August 16, 2017 at 2:52:09 PM UTC+1, Steve D'Aprano wrote: > On Wed, 16 Aug 2017 10:29 pm, breamoreboy wrote: > > > How do you expect to get four lines of output from the three function calls? > > In the REPL (the interactive interpreter) the result of evaluating the line is > print

Re: Proposed new syntax

2017-08-16 Thread Marco Buttu
On 10/08/2017 16:28, Steve D'Aprano wrote: What would you expect this syntax to return? [x + 1 for x in (0, 1, 2, 999, 3, 4) while x < 5] [1, 2, 3] For comparison, what would you expect this to return? (Without actually trying it, thank you.) [x + 1 for x in (0, 1, 2, 999, 3, 4) if x < 5]

Re: A small quiz question

2017-08-16 Thread breamoreboy
On Wednesday, August 16, 2017 at 12:45:13 PM UTC+1, Steve D'Aprano wrote: > On Wed, 16 Aug 2017 09:06 pm, Stefan Ram wrote: > > > I wrote my first Python quiz question! > > > > It goes like this: > > > > Can you predict (without trying it out) what the Python > > console will output afte

Cross-language comparison: function map and similar

2017-08-16 Thread Steve D'Aprano
Over in another thread, we've been talking about comprehensions and their similarities and differences from the functional map() operation. Reminder: map(chr, [65, 66, 67, 68]) will return ['A', 'B', 'C']. My questions for those who know languages apart from Python: Are there language implemen

Re: Proposed new syntax

2017-08-16 Thread Ben Finney
Steve D'Aprano writes: > If he wanted declarative semantics, why didn't he argue for > declarative syntax like "select...where", instead of choosing > procedural syntax which matches the actual procedural semantics given? The syntax “f(foo) for foo in bar if baz(foo)” is nicely declarative. > I

Re: A small quiz question

2017-08-16 Thread Steve D'Aprano
On Wed, 16 Aug 2017 11:38 pm, Ben Bacarisse wrote: > r...@zedat.fu-berlin.de (Stefan Ram) writes: > >> I wrote my first Python quiz question! >> >> It goes like this: >> >> Can you predict (without trying it out) what the Python >> console will output after the following three lines have

Automatic segmenting of large Kafka messages?

2017-08-16 Thread Skip Montanaro
When using Apache Kafka, the maximum message size can be defined in the configuration. If you have a lot of similarly sized messages, you can probably make a good estimate of a max message size. When the message sizes are highly variable, that's less certain. This presentation from an engineer at

Re: A small quiz question

2017-08-16 Thread Steve D'Aprano
On Wed, 16 Aug 2017 10:29 pm, breamore...@gmail.com wrote: > How do you expect to get four lines of output from the three function calls? In the REPL (the interactive interpreter) the result of evaluating the line is printed. -- Steve “Cheer up,” they said, “things could be worse.” So I cheere

Re: Proposed new syntax

2017-08-16 Thread jmp
On 08/10/2017 04:28 PM, Steve D'Aprano wrote: Every few years, the following syntax comes up for discussion, with some people saying it isn't obvious what it would do, and others disagreeing and saying that it is obvious. So I thought I'd do an informal survey. What would you expect this syntax

Re: A small quiz question

2017-08-16 Thread Ben Bacarisse
r...@zedat.fu-berlin.de (Stefan Ram) writes: > I wrote my first Python quiz question! > > It goes like this: > > Can you predict (without trying it out) what the Python > console will output after the following three lines have > been entered? > > def f(i): print(i); return i; > > f(4)**

Re: Proposed new syntax

2017-08-16 Thread Steve D'Aprano
On Tue, 15 Aug 2017 09:10 am, Ben Finney wrote: > Steve D'Aprano writes: > >> On Mon, 14 Aug 2017 07:59 pm, Ben Finney wrote: >> > You began by asking what people would expect syntax to mean. >> > >> > Then you expressed surprise that anyone would think a comprehension >> > would be interpreted

Re: A small quiz question

2017-08-16 Thread Steve D'Aprano
On Wed, 16 Aug 2017 09:06 pm, Stefan Ram wrote: > I wrote my first Python quiz question! > > It goes like this: > > Can you predict (without trying it out) what the Python > console will output after the following three lines have > been entered? > > def f(i): print(i); return i; > >

Re: A small quiz question

2017-08-16 Thread Joel Goldstick
On Wed, Aug 16, 2017 at 7:06 AM, Stefan Ram wrote: > I wrote my first Python quiz question! > > It goes like this: > > Can you predict (without trying it out) what the Python > console will output after the following three lines have > been entered? > > def f(i): print(i); return i; > >