Re: Code review

2014-11-05 Thread Jean-Michel Pichavant
- Original Message - > From: "C Smith" > I read that with 2.7 that I had to initialize class variables to > immutable types. I think because I was working with the lists before > they had been altered and were still empty lists. I will mess around > tomorrow with the classes you suggested

Re: Code review

2014-11-04 Thread C Smith
>Jean-Michel wrote: >replace > if left_to_act is None: >left_to_act = [] > self.left_to_act = left_to_act >by > self.left_to_act = left_to_act or [] I read that with 2.7 that I had to initialize class variables to immutable types. I think because I was working with the lists before they had

Re: Code review

2014-11-04 Thread sohcahtoa82
On Tuesday, November 4, 2014 12:35:32 PM UTC-8, John Gordon wrote: > C Smith writes: > > > I was wondering if I could get some feedback on the biggest thing I > > have done as an amateur Python coder. > > Comments. > > You need a *lot* more comments. > > Like, every line or two of code should

Re: Code review

2014-11-04 Thread John Gordon
C Smith writes: > I was wondering if I could get some feedback on the biggest thing I > have done as an amateur Python coder. Comments. You need a *lot* more comments. Like, every line or two of code should have a comment explaining what is being accomplished. Seriously. Every line or two.

Re: Code review

2014-11-04 Thread Jean-Michel Pichavant
- Original Message - > From: "C Smith" > To: python-list@python.org > Sent: Tuesday, 4 November, 2014 4:28:33 PM > Subject: Code review > > I was wondering if I could get some feedback on the biggest thing I > have done as an amateur Python coder. The sidepots algorithm isn't > correct ye

Re: Code Review for Paper, Rock, Scissors

2014-10-15 Thread Larry Hudson
On 10/14/2014 01:04 AM, Revenant wrote: Hi all! I'm new to Python and programming in general, and am trying to learn as much as I can about it. Anyway, for a basic first program I made a simple game of Paper, Rock, Scissors. For this program, I incorporated a main menu that presented three d

Re: Code Review for Paper, Rock, Scissors

2014-10-14 Thread Chris Angelico
On Tue, Oct 14, 2014 at 7:04 PM, Revenant wrote: > As previously stated, I am new to Python and would also like to see if any of > you programming gurus have some suggestions about how I can simplify code, > and also if there are any other good starter programs to work on to improve > my skills

Re: Code Review for Paper, Rock, Scissors

2014-10-14 Thread Glenn Hutchings
Hi there! Welcome to Python. On Tuesday, 14 October 2014 09:04:51 UTC+1, Revenant wrote: > I am new to Python and would also like to see if any of you programming > gurus have some suggestions about how I can simplify code, and also if > there are any other good starter programs to work on to i

Re: Code review?

2014-01-13 Thread Chris Angelico
On Tue, Jan 14, 2014 at 6:22 PM, Bob Martin wrote: > Does any Linux distro ship with Python 3? I haven't seen one. On most Debian-based distros, you can simply 'apt-get install python3', and you'll get some 3.x version (in Debian Squeeze, that's 3.1, Debian Wheezy packages 3.2; Ubuntu since Rari

Re: Code review?

2014-01-13 Thread Bayram Güçlü
On 14-01-2014 11:22, Bob Martin wrote: in 714500 20140113 233415 Chris Angelico wrote: On Tue, Jan 14, 2014 at 7:43 AM, Steven D'Aprano wrote: On Tue, 14 Jan 2014 03:40:25 +1100, Chris Angelico wrote: Incidentally, is there a reason you're using Python 2.6? You should be able to upgrade at

Re: Code review?

2014-01-13 Thread Bob Martin
in 714500 20140113 233415 Chris Angelico wrote: >On Tue, Jan 14, 2014 at 7:43 AM, Steven D'Aprano wrote: >> On Tue, 14 Jan 2014 03:40:25 +1100, Chris Angelico wrote: >> >>> Incidentally, is there a reason you're using Python 2.6? You should be >>> able to upgrade at least to 2.7, and Flask ought

Re: Code review?

2014-01-13 Thread Chris Angelico
On Tue, Jan 14, 2014 at 7:43 AM, Steven D'Aprano wrote: > On Tue, 14 Jan 2014 03:40:25 +1100, Chris Angelico wrote: > >> Incidentally, is there a reason you're using Python 2.6? You should be >> able to upgrade at least to 2.7, and Flask ought to work fine on 3.3 >> (the current stable Python). If

Re: Code review?

2014-01-13 Thread Steven D'Aprano
On Tue, 14 Jan 2014 03:40:25 +1100, Chris Angelico wrote: > Incidentally, is there a reason you're using Python 2.6? You should be > able to upgrade at least to 2.7, and Flask ought to work fine on 3.3 > (the current stable Python). If it's the beginning of your project, and > you have nothing bin

Re: Code review?

2014-01-13 Thread Chris Angelico
On Tue, Jan 14, 2014 at 3:29 AM, Adam wrote: > Hey all. New to the list. I’m working on a web app with 2.6 and Flask. I’m > still relatively new to python. Is there a chance to get a code review from > anyone? I really want someone to just tear up my code and tell me how to > increase my e

Re: code review

2012-07-17 Thread Albert van der Horst
In article , Duncan Booth wrote: >Steven D'Aprano wrote: > >> On Fri, 13 Jul 2012 12:30:47 +, Albert van der Horst wrote: >>> The worst of is, of course, = for assignment instead of := . This is >>> a convention that Python follows, to my dismay. >> >> *shrug* >> >> The worst is to use = for

Re: code review

2012-07-16 Thread Ben Finney
Duncan Booth writes: > Technically of course Python doesn't have assignment, it just binds > names. Names, or other references. I'd argue that Python has assignment, and assignment in Python is identical with binding references to objects. But then, the Python documentation refers to “variable

Re: code review

2012-07-16 Thread Duncan Booth
Steven D'Aprano wrote: > On Fri, 13 Jul 2012 12:30:47 +, Albert van der Horst wrote: >> The worst of is, of course, = for assignment instead of := . This is >> a convention that Python follows, to my dismay. > > *shrug* > > The worst is to use = for both equality and assignment, like some >

Re: code review

2012-07-14 Thread Terry Reedy
On 7/14/2012 5:26 AM, Ian Kelly wrote: On Fri, Jul 13, 2012 at 5:09 PM, Terry Reedy wrote: I believe the following rule is true: if a op b is True or False raises, Sorry, left out 'or' in 'or raises' I don't follow. Raises what? an Exception. then op is a potentially chained comparis

Re: code review

2012-07-14 Thread Ian Kelly
On Fri, Jul 13, 2012 at 5:09 PM, Terry Reedy wrote: > >> From now on, for each operator I would have to remember wether it >> is a supposedly comparison operator or not. > > > I believe the following rule is true: if a op b is True or False raises, I don't follow. Raises what? > then op is a po

Re: code review

2012-07-13 Thread Terry Reedy
From now on, for each operator I would have to remember wether it is a supposedly comparison operator or not. I believe the following rule is true: if a op b is True or False raises, then op is a potentially chained comparison operation. They are (not) equal (and (not) is), the 4 order compa

Re: code review

2012-07-13 Thread rusi
On Jul 13, 8:36 pm, Chris Angelico wrote: > On Sat, Jul 14, 2012 at 1:04 AM, Steven D'Aprano > > wrote: > > Actually, no. Is True less than False, or is it greater? In boolean > > algebra, the question has no answer. It is only an implementation detail > > of Python that chooses False < True. > >

Re: code review

2012-07-13 Thread Roy Smith
On Friday, July 6, 2012 9:58:10 AM UTC-4, Steven D'Aprano wrote: > (Sadly, when I say "we" I mean > collectively. Many language designers, and programmers, don't have the > foggiest clue as to what makes a good clean design. Hence C++ and PHP.) I'm not going to defend C++, but to be fair, a majo

Re: code review

2012-07-13 Thread Chris Angelico
On Sat, Jul 14, 2012 at 1:04 AM, Steven D'Aprano wrote: > Actually, no. Is True less than False, or is it greater? In boolean > algebra, the question has no answer. It is only an implementation detail > of Python that chooses False < True. Maybe in boolean algebra, but in code, it's handy to have

Re: code review

2012-07-13 Thread Steven D'Aprano
On Fri, 13 Jul 2012 12:30:47 +, Albert van der Horst wrote: >>Apart from Python, Mathematica, Perl 6, CoffeeScript, Cobra and Clay >>give chained comparisons the standard meaning. It is, or was, a feature >>request for Boo, but I can't tell whether it has been implemented or >>not. > > Algol

Re: code review

2012-07-13 Thread Albert van der Horst
In article <4ff0f8e0$0$29988$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: >On Sun, 01 Jul 2012 05:55:24 -0400, Terry Reedy wrote: > >> On 7/1/2012 2:54 AM, Steven D'Aprano wrote: >> >>> So no, Python has always included chained comparisons, and yes, it is >>> shameful that a langua

Re: Re: code review

2012-07-06 Thread lars van gemerden
On Sunday, July 1, 2012 5:48:40 PM UTC+2, Evan Driscoll wrote: > On 7/1/2012 4:54, Alister wrote: > > On Sat, 30 Jun 2012 23:45:25 -0500, Evan Driscoll wrote: > >> If I had seen that in a program, I'd have assumed it was a bug. > > > > You would? > > I have only been using python for 6 - 12 months

Re: code review

2012-07-04 Thread Mark Lawrence
On 04/07/2012 10:29, Paul Rudin wrote: Mark Lawrence writes: On 03/07/2012 03:25, John O'Hagan wrote: On Tue, 3 Jul 2012 11:22:55 +1000 I agree to some extent, but as a counter-example, when I was a child there a subject called "Weights and Measures" which is now redundant because of the Met

Re: code review

2012-07-04 Thread levi nie
2012/7/4 Paul Rudin > Mark Lawrence writes: > > > On 03/07/2012 03:25, John O'Hagan wrote: > >> On Tue, 3 Jul 2012 11:22:55 +1000 > >> > >> I agree to some extent, but as a counter-example, when I was a child > there > >> a subject called "Weights and Measures" which is now redundant because > o

Re: code review

2012-07-04 Thread Paul Rudin
Mark Lawrence writes: > On 03/07/2012 03:25, John O'Hagan wrote: >> On Tue, 3 Jul 2012 11:22:55 +1000 >> >> I agree to some extent, but as a counter-example, when I was a child there >> a subject called "Weights and Measures" which is now redundant because of the >> Metric system. I don't miss ho

Re: code review

2012-07-04 Thread Mark Lawrence
On 03/07/2012 22:54, Chris Angelico wrote: On Wed, Jul 4, 2012 at 6:13 AM, Dave Angel wrote: On 07/03/2012 12:05 PM, Mark Lawrence wrote: If I go to the moon I will weigh 2st 10lb (if my sums are correct :) but the equivalent Frenchman will still be 86kg. I hereby put this forward as proof tha

Re: code review

2012-07-04 Thread rusi
On Jul 4, 11:17 am, alex23 wrote: > On Jul 4, 3:39 pm, "Littlefield, Tyler" wrote: > > > I basically just stopped after a while. It got into a my language is > > better than your language, so I didn't see much constructive info. > > To be fair, it's more "my vision of the language is better than

Re: code review

2012-07-04 Thread alex23
On Jul 4, 3:39 pm, "Littlefield, Tyler" wrote: > I basically just stopped after a while. It got into a my language is > better than your language, so I didn't see much constructive info. To be fair, it's more "my vision of the language is better than yours" :) But yes, it should've been forked in

Re: code review

2012-07-03 Thread Littlefield, Tyler
On 7/3/2012 10:55 PM, Simon Cropper wrote: Some questions to Tyler Littlefield, who started this thread. Q1 -- Did you get any constructive feedback on your code? I did get some, which I appreciated. someone mentioned using PyLint. From reading, I found it was really really pedantic, so I use

Re: code review

2012-07-03 Thread Simon Cropper
On 04/07/12 13:53, Chris Angelico wrote: On Wed, Jul 4, 2012 at 12:57 PM, wrote: Well, if you waited until you had the password (however long) in a variable before you applied your maximum limits, the DoS ship has probably sailed already. Only because data transfer is usually more expensiv

Re: code review

2012-07-03 Thread Chris Angelico
On Wed, Jul 4, 2012 at 12:57 PM, wrote: > Well, if you waited until you had the password (however long) in a variable > before you applied your maximum limits, the DoS ship has probably sailed > already. Only because data transfer is usually more expensive than hashing. But I'd say that'll alw

Re: code review

2012-07-03 Thread kushal . kumaran+python
Ian Kelly wrote: >On Tue, Jul 3, 2012 at 11:53 AM, Kushal Kumaran > wrote: >> On Sat, Jun 30, 2012 at 3:34 PM, Alister >wrote: >>> On Fri, 29 Jun 2012 09:03:22 -0600, Littlefield, Tyler wrote: >>> On 6/29/2012 1:31 AM, Steven D'Aprano wrote: > On Thu, 28 Jun 2012 20:58:15 -0700, alex23

Re: code review

2012-07-03 Thread Chris Angelico
On Wed, Jul 4, 2012 at 6:13 AM, Dave Angel wrote: > On 07/03/2012 12:05 PM, Mark Lawrence wrote: >> If I go to the moon I will weigh 2st 10lb (if my sums are correct :) >> but the equivalent Frenchman will still be 86kg. I hereby put this >> forward as proof that the metric system is rubbish and w

Re: code review

2012-07-03 Thread Chris Angelico
On Wed, Jul 4, 2012 at 4:27 AM, Ian Kelly wrote: > On Tue, Jul 3, 2012 at 12:18 PM, John Gordon wrote: >> As a practical matter, doesn't there have to be *some* sort of limit? >> For example if the (encrypted) password is stored in a database, you can't >> exceed the table column width. > > Hopef

Re: code review

2012-07-03 Thread Dave Angel
On 07/03/2012 12:05 PM, Mark Lawrence wrote: > On 03/07/2012 16:53, Chris Angelico wrote: >> On Wed, Jul 4, 2012 at 1:50 AM, Mark Lawrence >> wrote: >>> On 03/07/2012 03:25, John O'Hagan wrote: On Tue, 3 Jul 2012 11:22:55 +1000 I agree to some extent, but as a counter-example,

Re: code review

2012-07-03 Thread Ian Kelly
On Tue, Jul 3, 2012 at 12:18 PM, John Gordon wrote: > In Kushal Kumaran > writes: > >> I haven't actually seen the rest of the code, but I would like to >> point out that applications placing maximum length limits on passwords >> are extremely annoying. > > As a practical matter, doesn't there

Re: code review

2012-07-03 Thread John Gordon
In Kushal Kumaran writes: > I haven't actually seen the rest of the code, but I would like to > point out that applications placing maximum length limits on passwords > are extremely annoying. As a practical matter, doesn't there have to be *some* sort of limit? For example if the (encrypted)

Re: code review

2012-07-03 Thread Ian Kelly
On Tue, Jul 3, 2012 at 11:53 AM, Kushal Kumaran wrote: > On Sat, Jun 30, 2012 at 3:34 PM, Alister wrote: >> On Fri, 29 Jun 2012 09:03:22 -0600, Littlefield, Tyler wrote: >> >>> On 6/29/2012 1:31 AM, Steven D'Aprano wrote: On Thu, 28 Jun 2012 20:58:15 -0700, alex23 wrote: > On Jun 29

Re: code review

2012-07-03 Thread Kushal Kumaran
On Sat, Jun 30, 2012 at 3:34 PM, Alister wrote: > On Fri, 29 Jun 2012 09:03:22 -0600, Littlefield, Tyler wrote: > >> On 6/29/2012 1:31 AM, Steven D'Aprano wrote: >>> On Thu, 28 Jun 2012 20:58:15 -0700, alex23 wrote: >>> On Jun 29, 12:57 pm, "Littlefield, Tyler" wrote: > I was curious if

Re: code review

2012-07-03 Thread Mark Lawrence
On 03/07/2012 16:53, Chris Angelico wrote: On Wed, Jul 4, 2012 at 1:50 AM, Mark Lawrence wrote: On 03/07/2012 03:25, John O'Hagan wrote: On Tue, 3 Jul 2012 11:22:55 +1000 I agree to some extent, but as a counter-example, when I was a child there a subject called "Weights and Measures" which

Re: code review

2012-07-03 Thread Mark Lawrence
On 03/07/2012 07:09, Dennis Lee Bieber wrote: On 03 Jul 2012 04:11:22 GMT, Steven D'Aprano declaimed the following in gmane.comp.python.general: One of my favourites is the league, which in the Middle Ages was actually defined as the distance that a man, or a horse, could walk in an hour.

Re: code review

2012-07-03 Thread Chris Angelico
On Wed, Jul 4, 2012 at 1:50 AM, Mark Lawrence wrote: > On 03/07/2012 03:25, John O'Hagan wrote: >> >> On Tue, 3 Jul 2012 11:22:55 +1000 >> >> I agree to some extent, but as a counter-example, when I was a child there >> a subject called "Weights and Measures" which is now redundant because of >> t

Re: code review

2012-07-03 Thread Mark Lawrence
On 03/07/2012 03:25, John O'Hagan wrote: On Tue, 3 Jul 2012 11:22:55 +1000 I agree to some extent, but as a counter-example, when I was a child there a subject called "Weights and Measures" which is now redundant because of the Metric system. I don't miss hogsheads and fathoms at all. John I

Re: code review

2012-07-03 Thread John O'Hagan
On Mon, 2 Jul 2012 22:10:00 -0700 (PDT) rusi wrote: > On Jul 3, 7:25 am, John O'Hagan wrote: > > > > I agree to some extent, but as a counter-example, when I was a child there > > a subject called "Weights and Measures" which is now redundant because of > > the Metric system. I don't miss hogshe

Re: code review

2012-07-03 Thread Roy Smith
In article , Dennis Lee Bieber wrote: > On 03 Jul 2012 04:11:22 GMT, Steven D'Aprano > declaimed the following in > gmane.comp.python.general: > > > > One of my favourites is the league, which in the Middle Ages was actually > > defined as the distance that a man, or a horse, could walk in a

Re: code review

2012-07-03 Thread Neil Cerutti
On 2012-07-02, Chris Angelico wrote: > On Tue, Jul 3, 2012 at 1:57 AM, Rick Johnson > wrote: >> Poor Chris. That's because you've been brainwashed into believing you >> must spoon feed your interpreter to get your code working correctly. >> Stop applying these naive assumptions to Python code. Pyt

Re: code review

2012-07-02 Thread Ben Finney
rusi writes: > Similar for standardized languages: Python's indentation is nice -- > except when you have to embed it into say, html If you can't write a ‘pre’ element for pre-formatted text, you don't have HTML http://www.w3.org/TR/html401/struct/text.html#h-9.3.4>. -- \ “Pinky, are you

Re: code review

2012-07-02 Thread rusi
On Jul 3, 7:25 am, John O'Hagan wrote: > > I agree to some extent, but as a counter-example, when I was a child there > a subject called "Weights and Measures" which is now redundant because of the > Metric system. I don't miss hogsheads and fathoms at all. > > Music is another field which could d

Re: code review

2012-07-02 Thread Steven D'Aprano
On Tue, 03 Jul 2012 12:25:59 +1000, John O'Hagan wrote: > On Tue, 3 Jul 2012 11:22:55 +1000 > Chris Angelico wrote: > >> On Tue, Jul 3, 2012 at 10:57 AM, Steven D'Aprano >> wrote: >> >> > Perhaps the world would be better off if mathematicians threw out the >> > existing precedence rules and r

Re: code review

2012-07-02 Thread John O'Hagan
On Tue, 3 Jul 2012 11:22:55 +1000 Chris Angelico wrote: > On Tue, Jul 3, 2012 at 10:57 AM, Steven D'Aprano > wrote: > > > Perhaps the world would be better off if mathematicians threw out the > > existing precedence rules and replaced them with a strict left-to-right > > precedence. (Personally

Re: code review

2012-07-02 Thread Chris Angelico
On Tue, Jul 3, 2012 at 10:57 AM, Steven D'Aprano wrote: > On Tue, 03 Jul 2012 02:55:48 +1000, Chris Angelico wrote: >> Oh yes, absolutely consistent. Consistency. It's a CR 1/2 monster found >> on page 153 of the 3.5th Edition Monster Manual. > > GvR is fond of quoting Ralph Waldo Emerson: > > "A

Re: code review

2012-07-02 Thread Steven D'Aprano
On Tue, 03 Jul 2012 02:55:48 +1000, Chris Angelico wrote: > On Tue, Jul 3, 2012 at 1:16 AM, Rick Johnson > wrote: >> py> 1 + 3 * 4 >> should ALWAYS equal 16! >> >> With parenthesis only used for grouping: py> a + (b*c) + d >> >> Which seems like the most consistent approach to me. > > Oh yes, ab

Re: code review

2012-07-02 Thread Chris Angelico
On Tue, Jul 3, 2012 at 5:06 AM, Thomas Jollans wrote: > On 07/02/2012 08:22 PM, Rick Johnson wrote: >> Agreed. I wish we had one language. One which had syntactical >> directives for scoping, blocks, assignments, etc, etc... >> >> BLOCK_INDENT_MARKER -> \t >> BLOCK_DEDENT_MARKER -> \n >> STATEMENT

Re: code review

2012-07-02 Thread Rick Johnson
On Jul 2, 2:06 pm, Thomas Jollans wrote: > On 07/02/2012 08:22 PM, Rick Johnson wrote: > > > Agreed. I wish we had one language. One which had syntactical > > directives for scoping, blocks, assignments, etc, etc... > > > BLOCK_INDENT_MARKER -> \t > > BLOCK_DEDENT_MARKER -> \n > > STATEMENT_TERMIN

Re: code review

2012-07-02 Thread Ian Kelly
On Sat, Jun 30, 2012 at 2:50 PM, Thomas Jollans wrote: > Which of the two comparisons is done first anyway? > "In the face of ambiguity, refuse the temptation to guess." I would consider that a pro, not a con, because the C-like way is much worse in this regard. Using operator chaining, is "1 <

Re: code review

2012-07-02 Thread Thomas Jollans
On 07/02/2012 08:22 PM, Rick Johnson wrote: > Agreed. I wish we had one language. One which had syntactical > directives for scoping, blocks, assignments, etc, etc... > > BLOCK_INDENT_MARKER -> \t > BLOCK_DEDENT_MARKER -> \n > STATEMENT_TERMINATOR -> \n > ASSIGNMENT_OPERATOR -> := > CONDITIONAL_IF

Re: code review

2012-07-02 Thread Rick Johnson
On Jul 2, 11:42 am, Chris Angelico wrote: > Rick, do you realize that you have > to spoon-feed the interpreter with spaces/tabs when other interpreters > just KNOW to drop back an indentation level when you close a brace? Yes. And significant white space is my favorite attribute of Python source

Re: code review

2012-07-02 Thread Chris Angelico
On Tue, Jul 3, 2012 at 1:16 AM, Rick Johnson wrote: > py> 1 + 3 * 4 > should ALWAYS equal 16! > > With parenthesis only used for grouping: > py> a + (b*c) + d > > Which seems like the most consistent approach to me. Oh yes, absolutely consistent. Consistency. It's a CR 1/2 monster found on page 1

Re: code review

2012-07-02 Thread Rick Johnson
On Jun 30, 9:06 pm, Steven D'Aprano wrote: > On Sun, 01 Jul 2012 00:05:26 +0200, Thomas Jollans wrote: > > Yes. My sole point, really, is that "normally", one would expect these > > two expressions to be equivalent: > > > a < b < c > > (a < b) < c > > Good grief. Why would you expect that? > > You

Re: code review

2012-07-02 Thread Chris Angelico
On Tue, Jul 3, 2012 at 1:57 AM, Rick Johnson wrote: > Poor Chris. That's because you've been brainwashed into believing you > must spoon feed your interpreter to get your code working correctly. > Stop applying these naive assumptions to Python code. Python knows > when you reach the end of a stat

Re: code review

2012-07-02 Thread Rick Johnson
On Jul 2, 3:20 am, Chris Angelico wrote: > On Mon, Jul 2, 2012 at 6:11 PM, Steven D'Aprano > > wrote: > > "c" < first_word < second_word == third_word < "x" > > > I'm sure I don't have to explain what that means -- that standard chained > > notation for comparisons is obvious and simple. > > > In

Re: code review

2012-07-02 Thread Terry Reedy
On 7/2/2012 1:20 AM, Dennis Lee Bieber wrote: Obviously, someone coming over from VB or R or any other single language x who hasn't read the Python reference is going to be surprised as something or other. So what. The manuals, including the tutorial, are there for a reason. The main poin

Re: code review

2012-07-02 Thread Thomas Jollans
On 07/02/2012 03:28 AM, Steven D'Aprano wrote: > We *really did have* somebody arguing that chained comparisons are Bad > because you can't stick parentheses around bits of it without changing > the semantics. That was an actual argument, not a straw-man. Ahem. It may have been sub-optimally phr

Re: code review

2012-07-02 Thread Thomas Jollans
On 07/02/2012 02:43 AM, Steven D'Aprano wrote: > On Sun, 01 Jul 2012 09:35:40 +0200, Thomas Jollans wrote: >> This is simply wrong. The comparisons are not acting as binary >> operators. > > Of course they are. Take this chained comparison: Technically, yes - two-input operations are happening. S

Re: code review

2012-07-02 Thread Chris Angelico
On Mon, Jul 2, 2012 at 6:11 PM, Steven D'Aprano wrote: > "c" < first_word < second_word == third_word < "x" > > I'm sure I don't have to explain what that means -- that standard chained > notation for comparisons is obvious and simple. > > In Python, you write it the normal way, as above. But some

Re: code review

2012-07-02 Thread Steven D'Aprano
On Mon, 02 Jul 2012 12:04:29 +1000, Chris Angelico wrote: >> Chained comparisons in the Python sense may be rare in computer >> languages, but it is the standard in mathematics and hardly needs to be >> explained to anyone over the age of twelve. That is a terrible >> indictment on the state of pr

Re: code review

2012-07-02 Thread Steven D'Aprano
On Sun, 01 Jul 2012 21:50:29 -0400, Devin Jeanpierre wrote: > On Sun, Jul 1, 2012 at 9:28 PM, Steven D'Aprano > wrote: >> Technically, < in Python is left-associative: a < b < c first evaluates >> a, not b or c. But it is left-associative under the rules of comparison >> operator chaining, not ar

Re: code review

2012-07-01 Thread John O'Hagan
On Sun, 01 Jul 2012 13:41:20 -0400 Dennis Lee Bieber wrote: > I'd think a true newcomer (to programming) would have NO > expectations... And if they'd had any complex math classes may actually > consider > if 1 < x < 10: > to be the norm [...] +1 I've only ever known Pyth

Re: code review

2012-07-01 Thread Chris Angelico
On Mon, Jul 2, 2012 at 11:28 AM, Steven D'Aprano wrote: > On Sun, 01 Jul 2012 16:33:15 +1000, Chris Angelico wrote: > >> On Sun, Jul 1, 2012 at 4:27 PM, Steven D'Aprano >> wrote: >>> Yes, you can find specially crafted examples where adding parentheses >>> in certain places, but not others, doesn

Re: code review

2012-07-01 Thread Devin Jeanpierre
On Sun, Jul 1, 2012 at 9:28 PM, Steven D'Aprano wrote: > Technically, < in Python is left-associative: a < b < c first evaluates > a, not b or c. But it is left-associative under the rules of comparison > operator chaining, not arithmetic operator chaining. Left-associativity is when a < b < c is

Re: code review

2012-07-01 Thread Devin Jeanpierre
On Sun, Jul 1, 2012 at 8:41 PM, Steven D'Aprano wrote: > On Sun, 01 Jul 2012 05:18:09 -0400, Devin Jeanpierre wrote: > Sheesh guys. Don't go hunting through the most obscure corners of > mathematics for examples of computer scientists who have invented their > own maths notation. (Which, by your o

Re: code review

2012-07-01 Thread Steven D'Aprano
On Sun, 01 Jul 2012 16:33:15 +1000, Chris Angelico wrote: > On Sun, Jul 1, 2012 at 4:27 PM, Steven D'Aprano > wrote: >> Yes, you can find specially crafted examples where adding parentheses >> in certain places, but not others, doesn't change the overall >> evaluation of the expression. > > My p

Re: code review

2012-07-01 Thread Steven D'Aprano
On Sun, 01 Jul 2012 05:55:24 -0400, Terry Reedy wrote: > On 7/1/2012 2:54 AM, Steven D'Aprano wrote: > >> So no, Python has always included chained comparisons, and yes, it is >> shameful that a language would force you to unlearn standard notation >> in favour of a foolish consistency with other

Re: code review

2012-07-01 Thread Steven D'Aprano
On Sun, 01 Jul 2012 09:35:40 +0200, Thomas Jollans wrote: > On 07/01/2012 04:06 AM, Steven D'Aprano wrote: >> On Sun, 01 Jul 2012 00:05:26 +0200, Thomas Jollans wrote: >> >>> As soon as you read it as a ternary operator, >> >> Well that's your problem. Why are you reading it as a ternary operato

Re: code review

2012-07-01 Thread Steven D'Aprano
On Sun, 01 Jul 2012 05:18:09 -0400, Devin Jeanpierre wrote: > Also, you claimed earlier that the notion of associative "<" is not > founded in mathematical notation. It really depends on whose > mathematical notation you use -- there's more than one, you know. For > example, it's reasonable to exp

Re: code review

2012-07-01 Thread HoneyMonster
On Sun, 01 Jul 2012 09:46:56 +0200, Thomas Jollans wrote: > I don't have PostgeSQL handy just now - what is the result of (1 < 2 < > 3) ? I bet it's the same error, which means the two are still > equivalent. $ psql misc psql (9.1.4) Type "help" for help. misc=# select (1 < 2); ?column? --

Re: Re: code review

2012-07-01 Thread Evan Driscoll
On 7/1/2012 4:54, Alister wrote: > On Sat, 30 Jun 2012 23:45:25 -0500, Evan Driscoll wrote: >> If I had seen that in a program, I'd have assumed it was a bug. > > You would? > I have only been using python for 6 - 12 months but in my past I > programmed microcontrollers in assembly. > > as soon

Re: code review

2012-07-01 Thread Terry Reedy
On 7/1/2012 2:54 AM, Steven D'Aprano wrote: So no, Python has always included chained comparisons, and yes, it is shameful that a language would force you to unlearn standard notation in favour of a foolish consistency with other operators. Comparisons aren't special because they return bools. T

Re: code review

2012-07-01 Thread Alister
On Sat, 30 Jun 2012 23:45:25 -0500, Evan Driscoll wrote: > On 6/30/2012 19:37, Chris Angelico wrote: >> On Sun, Jul 1, 2012 at 10:08 AM, Ben Finney >> wrote: >>> I know of no programming language that would give a newcomer to Python >>> that expectation. So where is the norm you're referring to?

Re: code review

2012-07-01 Thread Devin Jeanpierre
On Sun, Jul 1, 2012 at 3:28 AM, Ben Finney wrote: > Chris Angelico writes: >> C, SQL, REXX, and many other languages. > > So, languages without strong typing then. In that case, I revise my > statement: I know of no programming language with strong typing that > would give a newcomer to Python th

Re: code review

2012-07-01 Thread Thomas Jollans
On 07/01/2012 09:28 AM, Ben Finney wrote: > Chris Angelico writes: > >> On Sun, Jul 1, 2012 at 10:08 AM, Ben Finney >> wrote: >>> Thomas Jollans writes: >>> My sole point, really, is that "normally", one would expect these two expressions to be equivalent: a < b < c (a

Re: code review

2012-07-01 Thread Thomas Jollans
On 07/01/2012 04:06 AM, Steven D'Aprano wrote: > On Sun, 01 Jul 2012 00:05:26 +0200, Thomas Jollans wrote: > >> As soon as you read it as a ternary operator, > > Well that's your problem. Why are you reading it as a ternary operator? > It isn't one. It is a pair of chained binary operator. > >

Re: code review

2012-07-01 Thread Ben Finney
Chris Angelico writes: > On Sun, Jul 1, 2012 at 10:08 AM, Ben Finney > wrote: > > Thomas Jollans writes: > > > >> My sole point, really, is that "normally", one would expect these two > >> expressions to be equivalent: > >> > >> a < b < c > >> (a < b) < c > > > > What norm gives you that expec

Re: code review

2012-07-01 Thread Thomas 'PointedEars' Lahn
Evan Driscoll wrote: > On 6/30/2012 23:45, Evan Driscoll wrote: >> You may also >> want to put Java in there as well, as < is effectively not commutative >> in that language. (I didn't try C#.) > > I guess you could actually put Lua and Ruby into the roughly same > category as Java too. > > But

Re: Re: code review

2012-07-01 Thread Thomas 'PointedEars' Lahn
Evan Driscoll wrote: > On 6/30/2012 19:37, Chris Angelico wrote: >> On Sun, Jul 1, 2012 at 10:08 AM, Ben Finney >> wrote: >>> I know of no programming language that >>> would give a newcomer to Python that expectation. So where is the norm >>> you're referring to? >> >> C, SQL, REXX, and many ot

Re: code review

2012-07-01 Thread Chris Angelico
On Sun, Jul 1, 2012 at 4:54 PM, Steven D'Aprano wrote: > Not in English-speaking countries with a culture of writing chained > comparisons in mathematics and allowing them in natural language: > > "Rock is beaten by Paper, is beaten by Scissors". I would write that as: Rock is beaten by Paper, a

Re: code review

2012-06-30 Thread Steven D'Aprano
On Sun, 01 Jul 2012 13:48:04 +1000, Chris Angelico wrote: > On Sun, Jul 1, 2012 at 1:23 PM, Steven D'Aprano > wrote: >> All the worse for those languages, since they violate the semantics of >> mathematical notation. > > Not so. It simply means that booleans are nothing special. In REXX, > there

Re: code review

2012-06-30 Thread Chris Angelico
On Sun, Jul 1, 2012 at 4:27 PM, Steven D'Aprano wrote: > Yes, you can find specially crafted examples where adding parentheses in > certain places, but not others, doesn't change the overall evaluation of > the expression. My point was that adding parentheses around the tightest-binding operator

Re: code review

2012-06-30 Thread Steven D'Aprano
On Sun, 01 Jul 2012 14:23:36 +1000, Chris Angelico wrote: > On Sun, Jul 1, 2012 at 2:17 PM, Steven D'Aprano > wrote: >> Nonsense. Of course parens change the evaluation of the expression. >> That's what parens are for! > > The whole point of my example was that it wouldn't. Yes, you can find sp

Re: code review

2012-06-30 Thread Evan Driscoll
On 6/30/2012 23:45, Evan Driscoll wrote: > You may also > want to put Java in there as well, as < is effectively not commutative > in that language. (I didn't try C#.) I guess you could actually put Lua and Ruby into the roughly same category as Java too. But things get a little nastier in ==, as

Re: Re: code review

2012-06-30 Thread Evan Driscoll
On 6/30/2012 19:37, Chris Angelico wrote: > On Sun, Jul 1, 2012 at 10:08 AM, Ben Finney > wrote: >> I know of no programming language that >> would give a newcomer to Python that expectation. So where is the norm >> you're referring to? > > C, SQL, REXX, and many other languages. Some others: L

Re: code review

2012-06-30 Thread Chris Angelico
On Sun, Jul 1, 2012 at 2:07 PM, rusi wrote: > Kernighan and Ritchie admit they made a design mistake with their > operator precedences: > > http://en.wikipedia.org/wiki/C_%28programming_language%29#Criticism > The examples given there have nothing to do with the chaining of comparisons and how it

Re: code review

2012-06-30 Thread Chris Angelico
On Sun, Jul 1, 2012 at 2:17 PM, Steven D'Aprano wrote: > Nonsense. Of course parens change the evaluation of the expression. > That's what parens are for! The whole point of my example was that it wouldn't. ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: code review

2012-06-30 Thread Steven D'Aprano
On Sun, 01 Jul 2012 12:20:52 +1000, Chris Angelico wrote: > On Sun, Jul 1, 2012 at 12:06 PM, Steven D'Aprano > wrote: >> You can't just arbitrarily stick parentheses around parts of >> expressions and expect the result to remain unchanged. Order of >> evaluation matters: >> >> 2**3**4 != (2**3)**

Re: code review

2012-06-30 Thread rusi
On Jul 1, 8:23 am, Steven D'Aprano wrote: > On Sun, 01 Jul 2012 10:37:05 +1000, Chris Angelico wrote: > > On Sun, Jul 1, 2012 at 10:08 AM, Ben Finney > > wrote: > >> Thomas Jollans writes: > > >>> My sole point, really, is that "normally", one would expect these two > >>> expressions to be equiv

Re: code review

2012-06-30 Thread Chris Angelico
On Sun, Jul 1, 2012 at 1:23 PM, Steven D'Aprano wrote: > All the worse for those languages, since they violate the semantics of > mathematical notation. Not so. It simply means that booleans are nothing special. In REXX, there are no data types at all, and "1" and "0" are your booleans. In C, boo

  1   2   >