Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > code review

Reply
Thread Tools

code review

 
 
Mark Lawrence
Guest
Posts: n/a
 
      07-04-2012
On 04/07/2012 10:29, Paul Rudin wrote:
> Mark Lawrence <(E-Mail Removed)> 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 hogsheads and fathoms at all.
>>>
>>> John
>>>

>>
>> I weigh 13st 8lb - does this make me redundant?

>
> It might mean that you have some redundant weight
>


True indeed, although my beer free diet of the last 10 days (yes, 10
whole days) has at least got it down from 14 stone 2 pounds.

--
Cheers.

Mark Lawrence.



 
Reply With Quote
 
 
 
 
John O'Hagan
Guest
Posts: n/a
 
      07-06-2012
On Tue, 03 Jul 2012 23:39:20 -0600
"Littlefield, Tyler" <(E-Mail Removed)> wrote:

> 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 used PyFlakes
> instead.
> >
> > Q2 -- Did you feel that the process of submitting your code for review
> > met your expectation?

>
> There wasn't much more to review, so yes. The info I got was helpful and
> farther than it was before I started.
>
> > Q3 -- Would you recommend others doing this either on this forum or
> > other fora?
> >
> > It appears to me - third party watching the ongoing dialog - that the
> > tread has gone right off topic (some time ago) and someone should
> > really start a new thread under a new title/subject. Most of what I
> > have read does not appear to be discussing your code or how you could
> > improve your code.
> >

> 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. I've
> started reading from the bottom though, where it looks like it's back,
> and I do appreciate the rest of the info given, as well. Thanks again
> for the feedback.
>


As one of the perpetrators, I did apologise for being OT within the body of my
replies to OT posts, but I see the irony. I guess I just thought somebody else
would do it eventually. I hereby apologise for not taking the correct action,
and vow to do so in future: to change the subject line regardless of who
initially went OT, starting now.

Regards,
--
John

 
Reply With Quote
 
 
 
 
Simon Cropper
Guest
Posts: n/a
 
      07-06-2012
On 06/07/12 12:06, John O'Hagan wrote:
> On Tue, 03 Jul 2012 23:39:20 -0600
> "Littlefield, Tyler" <(E-Mail Removed)> wrote:
>
>> 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 used PyFlakes
>> instead.
>>>
>>> Q2 -- Did you feel that the process of submitting your code for review
>>> met your expectation?

>>
>> There wasn't much more to review, so yes. The info I got was helpful and
>> farther than it was before I started.
>>
>>> Q3 -- Would you recommend others doing this either on this forum or
>>> other fora?
>>>
>>> It appears to me - third party watching the ongoing dialog - that the
>>> tread has gone right off topic (some time ago) and someone should
>>> really start a new thread under a new title/subject. Most of what I
>>> have read does not appear to be discussing your code or how you could
>>> improve your code.
>>>

>> 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. I've
>> started reading from the bottom though, where it looks like it's back,
>> and I do appreciate the rest of the info given, as well. Thanks again
>> for the feedback.
>>

>
> As one of the perpetrators, I did apologise for being OT within the body of my
> replies to OT posts, but I see the irony. I guess I just thought somebody else
> would do it eventually. I hereby apologise for not taking the correct action,
> and vow to do so in future: to change the subject line regardless of who
> initially went OT, starting now.
>
> Regards,
> --
> John
>


thanks

bet this kills the conservation though...

Simon

 
Reply With Quote
 
Chris Angelico
Guest
Posts: n/a
 
      07-06-2012
On Fri, Jul 6, 2012 at 3:30 PM, Simon Cropper
<(E-Mail Removed)> wrote:
> bet this kills the conservation though...


Probably. Until someone trolls the list again and sets us all going...

I'm another of the worst perps, so in the words of Pooh-Bah, "I desire
to associate myself with that expression of regret".

It was a pretty good discussion actually. The only real problem was
the subject line.

ChrisA
 
Reply With Quote
 
Mark Lawrence
Guest
Posts: n/a
 
      07-06-2012
On 06/07/2012 08:45, Chris Angelico wrote:
> On Fri, Jul 6, 2012 at 3:30 PM, Simon Cropper
> <(E-Mail Removed)> wrote:
>> bet this kills the conservation though...

>
> Probably. Until someone trolls the list again and sets us all going...
>
> I'm another of the worst perps, so in the words of Pooh-Bah, "I desire
> to associate myself with that expression of regret".
>
> It was a pretty good discussion actually. The only real problem was
> the subject line.
>
> ChrisA
>


As far as I'm concerned nothing is OT here unless it is blatant trolling
or spamming. It makes for a far more interesting read than the groups
that have a policy of "if it's not in the standard, we won't discuss
it". The set of languages that start with the third letter of the
English language springs instantly to my mind.

Agreed that the subject line should be changed.

--
Cheers.

Mark Lawrence.



 
Reply With Quote
 
lars van gemerden
Guest
Posts: n/a
 
      07-06-2012
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 but in my past I
> > programmed microcontrollers in assembly.
> >
> > as soon as i saw it i understood it & thought great, like a light bulb
> > going on.

>
> It's not a matter of "I wouldn't have understood what the author was
> trying to do" (with a small caveat), it's a matter of "I'd have assumed
> that the author didn't understand the language semantics."
>
> I'm pretty sure it goes contrary to *every other programming language
> I've ever used* (and a couple that I haven't).
>
> I understand why Python does it, and it certainly is nice in that it
> matches typical mathematical notation, but the surprise quotient is
> *very* high in the PL world IMO.
>
> Evan


Avoiding suprises would mean we cannot improve languages, just reshuffle features?

Cheers, Lars
 
Reply With Quote
 
lars van gemerden
Guest
Posts: n/a
 
      07-06-2012
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 but in my past I
> > programmed microcontrollers in assembly.
> >
> > as soon as i saw it i understood it & thought great, like a light bulb
> > going on.

>
> It's not a matter of "I wouldn't have understood what the author was
> trying to do" (with a small caveat), it's a matter of "I'd have assumed
> that the author didn't understand the language semantics."
>
> I'm pretty sure it goes contrary to *every other programming language
> I've ever used* (and a couple that I haven't).
>
> I understand why Python does it, and it certainly is nice in that it
> matches typical mathematical notation, but the surprise quotient is
> *very* high in the PL world IMO.
>
> Evan


Avoiding suprises would mean we cannot improve languages, just reshuffle features?

Cheers, Lars
 
Reply With Quote
 
Steven D'Aprano
Guest
Posts: n/a
 
      07-06-2012
On Fri, 06 Jul 2012 04:22:18 -0700, lars van gemerden wrote:

> Avoiding suprises would mean we cannot improve languages, just reshuffle
> features?


No, of course not.

But there have been hundreds of programming languages, including many
different programming paradigms (procedural, imperative, object oriented,
stack-based, functional, logic, aspect, event-driven, natural language,
and many others), and tens of millions of person-days worth of experience
in programming. It's not 1960 any more, in general terms we mostly have a
good idea of what works and what doesn't. (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.)

The days when you could expect a brilliant new programming paradigm to
lead to a massive improvement in programmer productivity, like going from
assembly code to Fortran, are long gone. Now we look for incremental
improvements. (Although of course there is always a chance that some yet
unthought of new paradigm will revolutionise computer programming -- but
I wouldn't bet on it.)

When you're dealing with a well-designed, mature language like Python,
you are even more limited. There's only so many changes you can make
without turning it into a completely different language. And if you care
about backward compatibility and wish to avoid breaking existing
programs, there are even fewer changes that can be considered.

Many good programming features must be avoided, not because they are bad,
but because they don't match the rest of the language. Even though Python
copies features from many different paradigms and languages, there is a
mostly unified style of good Python code and any feature that doesn't
match that style should be left out. There's few things worse than a
language with random features just bolted on.


--
Steven
 
Reply With Quote
 
Albert van der Horst
Guest
Posts: n/a
 
      07-13-2012
In article <4ff0f8e0$0$29988$c3e8da3$(E-Mail Removed) om>,
Steven D'Aprano <(E-Mail Removed)> 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 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. They are special because of
>>> the way they are used.
>>>
>>> C treats comparison operators as if they were arithmetic operators, and
>>> so the behaviour of a chained comparison is the same as the behaviour
>>> as a sequence of arithmetic operators: a foolish consistency. Python
>>> treats comparison operators as comparison operators, and gives them
>>> behaviour appropriate to comparisons.

>>
>> I considered this a great feature of Python when I first learned it.
>> Reading about how rare it is among programming languages to treat
>> comparisons in the standard way in mathematics reinforces that.

>
>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 68 does not. It has promoted operator symbols to first
class citizens. In that context chained comparison operators
cannot be made to work.
Both Mathematica and Perl are ad-hoc-ish languages. I would
hate Python go that way.

From now on, for each operator I would have to remember wether it
is a supposedly comparison operator or not.

Comparison operations on booleans make sense.
I remember a FORTRAN compiler complaining about me
comparing LOGICALS. The lack of abstraction!

>
>
>C-like semantics are next to useless, except perhaps for obfuscation:
>
>http://stackoverflow.com/questions/4...3-return-true/
>
>And surprising:
>
>http://answers.yahoo.com/question/in...3172909AA4O9Hx
>
>C-like semantics are a clear case of purity of implementation overruling
>functional usefulness.


The worst of is, of course, = for assignment instead of := .
This is a convention that Python follows, to my dismay.

>
>--
>Steven


Groetjes Albert

--
--
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

 
Reply With Quote
 
Steven D'Aprano
Guest
Posts: n/a
 
      07-13-2012
On Fri, 13 Jul 2012 12:30:47 +0000, 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 68 does not. It has promoted operator symbols to first class
> citizens. In that context chained comparison operators cannot be made to
> work.
> Both Mathematica and Perl are ad-hoc-ish languages. I would hate Python
> go that way.


Perl 5 does not have chained comparisons. Perl 6, which is more designed
and less ad-hoc, does.

> From now on, for each operator I would have to remember wether it is a
> supposedly comparison operator or not.


Are you often in the habit of using operators *without* remembering what
they do? <wink>

I can't speak for you, but it isn't often that I've found myself not
remembering whether the less-than operator < means "compare two values"
or "multiply two values".


> Comparison operations on booleans make sense.


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.

Of course, equality and inequality make sense for all values. But the
other comparison operators, < <= >= > only make sense for values which
are ordered, like real numbers (but not complex numbers), strings, and
similar, or for set comparisons (subset and superset). Arbitrary types
may not define comparison operators.


> I remember a FORTRAN
> compiler complaining about me comparing LOGICALS. The lack of
> abstraction!


The opposite: LOGICALS are abstract values which do not define greater
than or less than.

> 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 BASICs.
At least Python does not allow assignment as an expression, so you can't
make the typical C error of:

if x = y: do_something() # oops meant x == y



--
Steven
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is code review? (Java code review) www Java 51 05-15-2007 01:10 PM
Secure Python code - volunteers for code review? andrew blah Python 6 10-17-2004 01:17 AM
Re: Secure Python code - volunteers for code review? Josiah Carlson Python 1 10-13-2004 03:05 PM
Code write \ code review productivity Volodymyr Sadovyy Java 8 04-25-2004 03:30 AM
Code review of cross platform code sample Otto Wyss C++ 5 09-07-2003 02:06 PM



Advertisments