Re: I'm wrong or Will we fix the ducks limp?

2016-06-06 Thread Chris Angelico
On Tue, Jun 7, 2016 at 4:33 PM, Gregory Ewing wrote: > Steven D'Aprano wrote: >> >> I think I'm on >> fairly solid ground to say that a language that is just like C except that >> it allocates variables in a hash table at runtime, using runtime lookups >> for variable access, would not satisfy the

Re: I'm wrong or Will we fix the ducks limp?

2016-06-06 Thread Gregory Ewing
Steven D'Aprano wrote: I think I'm on fairly solid ground to say that a language that is just like C except that it allocates variables in a hash table at runtime, using runtime lookups for variable access, would not satisfy the C89 or C99 standards. I wouldn't be so sure about that. Modern C s

Re: I'm wrong or Will we fix the ducks limp?

2016-06-06 Thread Gregory Ewing
Steven D'Aprano wrote: I never said that the string "x" is the same thing as the variable x. Maybe you didn't, but some people insist we shouldn't use the term "variable" when talking about python, but use "name" instead. I was pointing out that those two words don't have the same connotations

Re: I'm wrong or Will we fix the ducks limp?

2016-06-06 Thread Gregory Ewing
Steven D'Aprano wrote: Even if you were right that objects must exist at a single well-defined location, that is strictly irrelevant. That's implementation, not interface. We're talking about mental models. Sure, you could come up with some kind of Tardis-like mental model where objects exist i

Re: for / while else doesn't make sense

2016-06-06 Thread Ian Kelly
On Mon, Jun 6, 2016 at 6:51 PM, Lawrence D’Oliveiro wrote: > On Sunday, June 5, 2016 at 11:43:20 PM UTC+12, Marko Rauhamaa wrote: >> I often experiment with different loop constructs to find the one most >> pleasing to the eye. Working directly off iterators is quite rare but a >> while-vs-for con

Re: for / while else doesn't make sense

2016-06-06 Thread Dan Sommers
On Mon, 06 Jun 2016 17:51:24 -0700, Lawrence D’Oliveiro wrote: > It is nice to have a common, versatile looping form which can be > arranged in different ways to suit the problem at hand. That’s why I > like the C-style for-statement. [example snipped] I used to write a lot of assembly code, for

Re: Everything good about Python except GUI IDE?

2016-06-06 Thread Lawrence D’Oliveiro
On Sunday, February 28, 2016 at 12:19:21 AM UTC+13, wrong.a...@gmail.com wrote: > I have some VB forms with more than a hundred objects. If I cannot drag and > drop text boxes, list boxes, labels, etc., it will be too much work to create > that with several lines of code for each object. You mean

Re: for / while else doesn't make sense

2016-06-06 Thread Lawrence D’Oliveiro
On Sunday, June 5, 2016 at 11:43:20 PM UTC+12, Marko Rauhamaa wrote: > Then, you might overdo constructs like lambdas and maps. Who says you can have too many lambdas? -- https://mail.python.org/mailman/listinfo/python

Re: for / while else doesn't make sense

2016-06-06 Thread Lawrence D’Oliveiro
On Sunday, June 5, 2016 at 11:43:20 PM UTC+12, Marko Rauhamaa wrote: > I often experiment with different loop constructs to find the one most > pleasing to the eye. Working directly off iterators is quite rare but a > while-vs-for consideration is frequent. Also, should the stepping part > be in th

Re: Operator precedence problem

2016-06-06 Thread Gregory Ewing
MRAB wrote: In Pascal, "and" has the same precedence as "*" and "or" has the same precedence as "+". Which was annoying, because it gave them higher precedence than the comparison operators, so instead of a = b and c > d you had to write (a = b) and (c > d) -- Greg -- https://mail.py

Re: Operator precedence problem

2016-06-06 Thread Gregory Ewing
Peter Pearson wrote: c b a**(b**c) = a Also, in mathematical texts it's usually written with the c smaller than the b, and the b smaller than the a, which helps to make the precedence clear. We can't do that in Python, unforunately. Unless we allow writing the

Re: [Q] ImportError by __import__() on Python >= 3.4

2016-06-06 Thread Michael Selik
On Thu, Jun 2, 2016 at 10:06 AM Makoto Kuwata wrote: > I have a trouble around __import__(). > The docs for __import__ strongly recommend that you use importlib instead https://docs.python.org/3.5/library/importlib.html#importlib.import_module The docs for ``importlib.import_module`` suggest th

Re: I'm wrong or Will we fix the ducks limp?

2016-06-06 Thread BartC
On 06/06/2016 17:19, Steven D'Aprano wrote: (2) The "variables are like boxes" metaphor applies to static languages like C and Pascal, where the compiler has knowledge of what variables will exist. Such languages allocate space for the variables at compile time, usually using fixed memory locati

Re: I'm wrong or Will we fix the ducks limp?

2016-06-06 Thread Marko Rauhamaa
Random832 : > The box metaphor as I understand it involves a lot of boxes, which may > contain arrows (call them pointers, references, or whatever) emerging > from them pointing to other boxes, which are all free-floating with no > implication that any of them are fixed locations or are not > dyna

Re: I'm wrong or Will we fix the ducks limp?

2016-06-06 Thread Random832
On Mon, Jun 6, 2016, at 14:59, Steven D'Aprano wrote: > "Variables as boxes" is a long-standing, well-known metaphor for the C > and > Pascal variable model, one where the value is copied into the box > (metaphorically), or to be more precise, where variables have fixed > locations and on assignmen

Re: Operator precedence problem

2016-06-06 Thread Ben Bacarisse
Rustom Mody writes: > Kernghan/Thomson/Ritchie (dont remember which) actually admitted to the > fact that these precedences are wrong > The mistake that C creators made was to treat bitwise operators as > *logical* rather than as *arithmetic* It was more that they did not take the opportunity t

Re: Operator precedence problem

2016-06-06 Thread MRAB
On 2016-06-06 19:44, Random832 wrote: On Mon, Jun 6, 2016, at 13:07, Steven D'Aprano wrote: Blimey, you're right. I always thought `and` and `or` had the same precedence. And now that I know better, I have no doubt that I will forget it again. A good way to remember it is that "and" is analogo

Re: Recommendation for GUI lib?

2016-06-06 Thread Dietmar Schwertberger
On 05.06.2016 01:08, John Pote wrote: Qt and Qt Creator often come up in searches for Python GUI libraries. I need to decide weather to upgrade to wxPython.Phoenix and Python 3.5 (as soon as I upgrade to win 7!) or switch to Qt which I don't know at all. It would be interesting to hear your exp

Re: I'm wrong or Will we fix the ducks limp?

2016-06-06 Thread Steven D'Aprano
On Tue, 7 Jun 2016 02:57 am, Random832 wrote: > On Mon, Jun 6, 2016, at 12:19, Steven D'Aprano wrote: >> (2) The "variables are like boxes" metaphor applies to static languages >> like >> C and Pascal, where the compiler has knowledge of what variables will >> exist. Such languages allocate space

Re: Operator precedence problem

2016-06-06 Thread Marko Rauhamaa
Random832 : > A good way to remember it is that "and" is analogous to > multiplication, and "or" is analogous to addition. Which is, I assume, > _why_ they have the same precedence. (why ^ is between | and &, > though, is a mystery to me.) APL had a good way of remembering operator precedence: eve

Re: Operator precedence problem

2016-06-06 Thread Random832
On Mon, Jun 6, 2016, at 13:07, Steven D'Aprano wrote: > Blimey, you're right. I always thought `and` and `or` had the same > precedence. And now that I know better, I have no doubt that I will > forget > it again. A good way to remember it is that "and" is analogous to multiplication, and "or" is

Re: Operator precedence problem

2016-06-06 Thread Rustom Mody
On Monday, June 6, 2016 at 7:27:18 PM UTC+5:30, Random832 wrote: > On Mon, Jun 6, 2016, at 01:46, Lawrence D’Oliveiro wrote: > > On Monday, June 6, 2016 at 4:06:20 AM UTC+12, Uri Even-Chen wrote: > > > Never write expressions, such as 2 ** 3 ** 2 or even 2 * 4 > > > + 5, without parentheses. > >

Re: Operator precedence problem

2016-06-06 Thread Steven D'Aprano
On Mon, 6 Jun 2016 11:57 pm, Random832 wrote: > Okay, can we settle on, as a principle, "the basic arithmetic operators > (not to include **) are the only ones whose precedence can be presumed > to be obvious to all readers, Agreed. > and other expressions may/should have > parentheses to mak

Re: Operator precedence problem

2016-06-06 Thread Jon Ribbens
On 2016-06-06, Chris Angelico wrote: > On Tue, Jun 7, 2016 at 2:05 AM, Jon Ribbens > wrote: >> On 2016-06-06, Chris Angelico wrote: >>> In that case, please never insult the intelligence of your future >>> readers by including any of these parentheses: >>> >>> x = 1 + (2 * 3) >> >> I'm not sure w

Re: Operator precedence problem

2016-06-06 Thread Peter Pearson
On Mon, 6 Jun 2016 02:24:37 +1000, Chris Angelico wrote: > On Sun, Jun 5, 2016 at 4:53 PM, ICT Ezy wrote: > 2 ** 3 ** 2 >> Answer is 512 >> Why not 64? >> Order is right-left or left-right? > > This example follows the mathematical standard; you start from the > "top" (the right hand side), a

Re: I'm wrong or Will we fix the ducks limp?

2016-06-06 Thread Random832
On Mon, Jun 6, 2016, at 12:19, Steven D'Aprano wrote: > (2) The "variables are like boxes" metaphor applies to static languages > like > C and Pascal, where the compiler has knowledge of what variables will > exist. Such languages allocate space for the variables at compile time, > usually using fi

Re: Operator precedence problem

2016-06-06 Thread Grant Edwards
On 2016-06-06, Chris Angelico wrote: > On Tue, Jun 7, 2016 at 1:27 AM, Jon Ribbens > wrote: You should put brackets around expressions when it's at all unclear what the meaning is. You could think of them a bit like "active comments" I suppose. >>> >>> Your code should keep noise t

Re: Operator precedence problem

2016-06-06 Thread Peter Otten
Marko Rauhamaa wrote: > Random832 : > >> Sure, it's obvious to _me_ that << and >> have higher precedence than & >> and |, and that "and" has a higher precedence than "or", but can I >> assume the other people know this? > > No need to assume. Just read the spec: > >lambda Lambda ex

Re: Operator precedence problem

2016-06-06 Thread Chris Angelico
On Tue, Jun 7, 2016 at 2:05 AM, Jon Ribbens wrote: > On 2016-06-06, Chris Angelico wrote: >> On Tue, Jun 7, 2016 at 1:27 AM, Jon Ribbens >> wrote: > You should put brackets around expressions when it's at all unclear > what the meaning is. You could think of them a bit like "active >

Re: I'm wrong or Will we fix the ducks limp?

2016-06-06 Thread Steven D'Aprano
On Mon, 6 Jun 2016 04:37 pm, Gregory Ewing wrote: > Steven D'Aprano wrote: >> The *name* "x" is an entity which is bound to (i.e. a reference to) the >> object 99, in some specific namespace, at some specific time. The name >> itself is an English word consisting of a single letter, "x". > > This

Re: Operator precedence problem

2016-06-06 Thread Jon Ribbens
On 2016-06-06, Chris Angelico wrote: > On Tue, Jun 7, 2016 at 1:27 AM, Jon Ribbens > wrote: You should put brackets around expressions when it's at all unclear what the meaning is. You could think of them a bit like "active comments" I suppose. >>> >>> Your code should keep noise to

Re: Don't put your software in the public domain

2016-06-06 Thread Steven D'Aprano
On Mon, 6 Jun 2016 03:54 pm, Nobody wrote: > On Sat, 04 Jun 2016 12:28:33 +1000, Steven D'Aprano wrote: > >>> OTOH, a Free software licence is unilateral; the author grants the user >>> certain rights, with the user providing nothing in return. >> >> That's not the case with the GPL. >> >> The

Re: Operator precedence problem

2016-06-06 Thread Chris Angelico
On Tue, Jun 7, 2016 at 1:27 AM, Jon Ribbens wrote: >>> You should put brackets around expressions when it's at all unclear >>> what the meaning is. You could think of them a bit like "active >>> comments" I suppose. >> >> Your code should keep noise to the minimum. > > Sensible and beneficial comm

Re: I'm wrong or Will we fix the ducks limp?

2016-06-06 Thread Steven D'Aprano
On Mon, 6 Jun 2016 02:08 pm, Random832 wrote: > On Sun, Jun 5, 2016, at 23:52, Steven D'Aprano wrote: >> Certainly not. x = y = 999 is required to bind the same object to x and >> y. > > My statement was that if two variables can be bound to the same object, > then variables *cannot* contain obje

Re: Operator precedence problem

2016-06-06 Thread Marko Rauhamaa
Jon Ribbens : > On 2016-06-06, Marko Rauhamaa wrote: >> You *can* assume other people have read the spec. Even more >> importantly, you can assume the Python interpreter complies with the >> spec. > > Obviously the latter is true (or at least, it's true except when it's > false). The former howev

Re: Operator precedence problem

2016-06-06 Thread Jon Ribbens
On 2016-06-06, Marko Rauhamaa wrote: > Jon Ribbens : >> On 2016-06-06, Marko Rauhamaa wrote: >>> You *can* assume other people have read the spec. Even more >>> importantly, you can assume the Python interpreter complies with the >>> spec. >> >> Obviously the latter is true (or at least, it's tru

Re: Operator precedence problem

2016-06-06 Thread Marko Rauhamaa
Random832 : > On Mon, Jun 6, 2016, at 10:22, Marko Rauhamaa wrote: >> You *can* assume other people have read the spec. Even more >> importantly, you can assume the Python interpreter complies with the >> spec. > > I can assume the python interpreter will accept tabs as indents too, > that doesn't

Re: Operator precedence problem

2016-06-06 Thread Jon Ribbens
On 2016-06-06, Marko Rauhamaa wrote: > Random832 : >> Sure, it's obvious to _me_ that << and >> have higher precedence than & >> and |, and that "and" has a higher precedence than "or", but can I >> assume the other people know this? > > No need to assume. Just read the spec: The spec tells you t

Re: OT: limit number of connections from browser to my server?

2016-06-06 Thread Grant Edwards
On 2016-05-16, Grant Edwards wrote: [...] > Is there any way to limit the number of connections a browser uses to > download a web page? Browser writers seems to assume that all https > servers are massively parallel server farms with hardware crypto > support. In case anybody is still wonderin

Re: Operator precedence problem

2016-06-06 Thread Random832
On Mon, Jun 6, 2016, at 10:22, Marko Rauhamaa wrote: > You *can* assume other people have read the spec. Even more importantly, > you can assume the Python interpreter complies with the spec. I can assume the python interpreter will accept tabs as indents too, that doesn't make it good style. Req

Re: I'm wrong or Will we fix the ducks limp?

2016-06-06 Thread jfine2358
On Friday, June 3, 2016 at 3:20:42 PM UTC+1, Sayth Renshaw wrote: > pyqFiles = [] > for filename in sorted(file_list): > pyqFiles = pyqFiles.append(pq(filename=my_dir + filename)) This won't end well. The return value from [].append(...) is None. >>> [].append(0) is None True Th

Re: Operator precedence problem

2016-06-06 Thread Marko Rauhamaa
Random832 : > Sure, it's obvious to _me_ that << and >> have higher precedence than & > and |, and that "and" has a higher precedence than "or", but can I > assume the other people know this? No need to assume. Just read the spec: lambda Lambda expression if – else Conditional

Re: Trying to pass sys.argv as (int argc, char **argv) using ctypes

2016-06-06 Thread Mark Summerfield
Thanks, that works! And also thanks for the excellent explanations of each part. -- https://mail.python.org/mailman/listinfo/python-list

Re: Operator precedence problem

2016-06-06 Thread Random832
On Mon, Jun 6, 2016, at 01:46, Lawrence D’Oliveiro wrote: > On Monday, June 6, 2016 at 4:06:20 AM UTC+12, Uri Even-Chen wrote: > > Never write expressions, such as 2 ** 3 ** 2 or even 2 * 4 > > + 5, without parentheses. > > That leads to the code equivalent of >

Re: Trying to pass sys.argv as (int argc, char **argv) using ctypes

2016-06-06 Thread eryk sun
On Mon, Jun 6, 2016 at 9:50 AM, Mark Summerfield wrote: > > Lib = ctypes.cdll.LoadLibrary("libthing") Use ctypes.CDLL('libthing'). It's simpler, plus it's the only way to pass the handle, mode, and use_errno parameters if you need them. > LibOpen.restype = ctypes.c_int This line isn't required

Re: errorhandler 2.0.0 Released!

2016-06-06 Thread Pavel S
Hi, can you explain, why is the attribute 'fired' class-level and not instance-level? There must be good reason for modifying class attribute from instance. Dne pondělí 6. června 2016 15:26:08 UTC+2 Chris Withers napsal(a): > Hi All, > > errorhandler is a tiny but useful logging handler for th

errorhandler 2.0.0 Released!

2016-06-06 Thread Chris Withers
Hi All, errorhandler is a tiny but useful logging handler for the python logging framework. It lets you tell when logging above a certain level has occurred, even if it's not in code you can control. I'm pleased to announce the release of errorhandler 2.0.0 featuring the following: - Suppo

Re: Taking two and more data frames and extracting data on unique keys in python

2016-06-06 Thread Michael Selik
On Sun, Jun 5, 2016 at 7:05 AM Danish Hussain wrote: > Please me know if clarification is needed. > Could you clarify what your question is? Did you encounter an error while coding the solution? -- https://mail.python.org/mailman/listinfo/python-list

Re: Anyone know a donation app codebase?

2016-06-06 Thread Michael Selik
On Sun, Jun 5, 2016 at 3:26 PM Ben Finney wrote: > Albert writes: > > > Thank you for your answer Ben, > > You're welcome. Please note that top-posting is poor etiquette for > discussions; instead, interleave your response like a written dialogue. > See https://en.wikipedia.org/wiki/Posting_styl

Re: Don't put your software in the public domain

2016-06-06 Thread Paul Rudin
Nobody writes: > On Sat, 04 Jun 2016 12:28:33 +1000, Steven D'Aprano wrote: > >>> OTOH, a Free software licence is unilateral; the author grants the user >>> certain rights, with the user providing nothing in return. >> >> That's not the case with the GPL. >> >> The GPL requires the user (not t

Re: Would like to see python script output

2016-06-06 Thread Michael Selik
On Mon, Jun 6, 2016 at 3:12 AM Archana Sonavane wrote: > I have ganglia python script, i would like to see output of each code > block. > > Could you please guide. I don't have any idea about python. > Do you know how to run a Python script? Have you read through the Python tutorial? https://do

Re: I'm wrong or Will we fix the ducks limp?

2016-06-06 Thread BartC
On 05/06/2016 07:37, Steven D'Aprano wrote: On Sun, 5 Jun 2016 01:17 pm, Lawrence D’Oliveiro wrote: On Saturday, June 4, 2016 at 3:55:12 AM UTC+12, Matt Wheeler wrote: It's best to think of them as names, rather than variables, as names in python don't behave quite how you'll expect variables

Re: Operator precedence problem

2016-06-06 Thread Gary Herron
On 06/04/2016 11:53 PM, ICT Ezy wrote: 2 ** 3 ** 2 Answer is 512 Why not 64? Order is right-left or left-right? Evidently right to left, but you already figured that out. Python 3.5.1+ (default, Mar 30 2016, 22:46:26) [GCC 5.3.1 20160330] on linux Type "help", "copyright", "credits" or "licen

Re: I'm wrong or Will we fix the ducks limp?

2016-06-06 Thread Chris Angelico
On Mon, Jun 6, 2016 at 2:08 PM, Random832 wrote: > My statement was that if two variables can be bound to the same object, > then variables *cannot* contain objects. The object has to exist > somewhere, and this requirement means that the variables cannot be where > the objects live. Then the pro

Re: I'm wrong or Will we fix the ducks limp?

2016-06-06 Thread Marko Rauhamaa
Antoon Pardon : > A reference is not pointer. When you use a reference parameter in > Pascal, it behave like an ordinary parameter within the procedure > block, you don't have to treat it like a pointer. The word "reference" as used in the Python standards documentation is not the same as "refere

Trying to pass sys.argv as (int argc, char **argv) using ctypes

2016-06-06 Thread Mark Summerfield
Hi, I have a setup roughly like this: import ctypes import sys Lib = ctypes.cdll.LoadLibrary("libthing") c_char_pp = ctypes.POINTER(ctypes.c_char_p) LibOpen = Lib.Open LibOpen.argtypes = (ctypes.c_int, # argc c_char_pp) # argv LibOpen.restype = ctypes.c_int

Re: I'm wrong or Will we fix the ducks limp?

2016-06-06 Thread Antoon Pardon
Op 06-06-16 om 05:52 schreef Steven D'Aprano: > On Mon, 6 Jun 2016 03:42 am, Random832 wrote: > >> On Sun, Jun 5, 2016, at 02:37, Steven D'Aprano wrote: >>> No they don't. You are confusing the implementation with the programming >>> model. >>> >>> Following the assignment: >>> >>> x = 99 >>> >>> i

ANN: eGenix PyRun - One file Python Runtime 2.2.1

2016-06-06 Thread eGenix Team: M.-A. Lemburg
ANNOUNCING eGenix PyRun - One file Python Runtime Version 2.2.1 An easy-to-use single file relocatable Python run-time - available for Linux, Mac OS X and Unix

Re: I'm wrong or Will we fix the ducks limp?

2016-06-06 Thread Marko Rauhamaa
Random832 : > On Sun, Jun 5, 2016, at 15:20, Marko Rauhamaa wrote: >> I say None is a wooden post, you say None is a puppy. >> >> What piece of Python code could put our dispute to rest? > > isinstance(None, object) Well, the wooden post is an object as are all puppies. It's bad enough to objec

Re: Urgent - Would like to see output of each block of python

2016-06-06 Thread Archana Sonavane
On Monday, June 6, 2016 at 12:35:55 PM UTC+5:30, Chris Rebert wrote: > On Sun, Jun 5, 2016 at 11:57 PM, Archana Sonavane > wrote: > > Hi Team, > > > > I don't have any idea about python scripts, i have ganglia tool python > > scripts. > > > > I would like see the output of each code block, could

Re: Spread a class over multiple files

2016-06-06 Thread dieter
Mark Summerfield writes: > Sometimes I want to spread a class over multiple files. When I run into such a use case, I use (multiple) inheritance -- with "mixin class"es. Each "mixin class" handles some important aspect and is only loosely coupled with maybe a common base class and the other asp

Would like to see python script output

2016-06-06 Thread Archana Sonavane
Hello, I have ganglia python script, i would like to see output of each code block. Could you please guide. I don't have any idea about python. My scripts as follows: #!/usr/bin/env python # # ganglia-api.py - Ganglia Metric API # ###

Re: Urgent - Would like to see output of each block of python

2016-06-06 Thread Chris Rebert
On Sun, Jun 5, 2016 at 11:57 PM, Archana Sonavane wrote: > Hi Team, > > I don't have any idea about python scripts, i have ganglia tool python > scripts. > > I would like see the output of each code block, could you please guide. > > The code as follows: With regard to your Subject line, please

Urgent - Would like to see output of each block of python

2016-06-06 Thread Archana Sonavane
Hi Team, I don't have any idea about python scripts, i have ganglia tool python scripts. I would like see the output of each code block, could you please guide. The code as follows: #!/usr/bin/env python # # ganglia-api.py - Ganglia Metric API #