Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #46708 > unrolled thread
| Started by | Rick Johnson <rantingrickjohnson@gmail.com> |
|---|---|
| First post | 2013-06-02 10:04 -0700 |
| Last post | 2013-06-03 15:11 -0400 |
| Articles | 20 on this page of 109 — 26 participants |
Back to article view | Back to comp.lang.python
PyWart: The problem with "print" Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-02 10:04 -0700
Re: PyWart: The problem with "print" Chris Angelico <rosuav@gmail.com> - 2013-06-03 03:20 +1000
Re: PyWart: The problem with "print" Dan Sommers <dan@tombstonezero.net> - 2013-06-02 17:49 +0000
Re: PyWart: The problem with "print" Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-02 11:18 -0700
Re: PyWart: The problem with "print" Ned Batchelder <ned@nedbatchelder.com> - 2013-06-02 16:45 -0400
Re: PyWart: The problem with "print" Michael Torrie <torriem@gmail.com> - 2013-06-02 23:49 -0600
Re: PyWart: The problem with "print" Chris Angelico <rosuav@gmail.com> - 2013-06-03 17:17 +1000
Re: PyWart: The problem with "print" Alister <alister.ware@ntlworld.com> - 2013-06-03 08:01 +0000
Re: PyWart: The problem with "print" Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-02 11:09 -0700
Re: PyWart: The problem with "print" Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-02 19:03 +0000
Re: PyWart: The problem with "print" Chris Angelico <rosuav@gmail.com> - 2013-06-03 06:21 +1000
Re: PyWart: The problem with "print" jmfauth <wxjmfauth@gmail.com> - 2013-06-04 05:23 -0700
Re: PyWart: The problem with "print" rusi <rustompmody@gmail.com> - 2013-06-04 06:29 -0700
Re: PyWart: The problem with "print" Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-06-04 14:35 +0100
Re: PyWart: The problem with "print" Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-05 05:03 +0000
Re: PyWart: The problem with "print" Andrew Berg <robotsondrugs@gmail.com> - 2013-06-02 12:30 -0500
Re: PyWart: The problem with "print" Chris Angelico <rosuav@gmail.com> - 2013-06-03 03:34 +1000
Re: PyWart: The problem with "print" Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-02 18:58 +0000
Re: PyWart: The problem with "print" Chris Angelico <rosuav@gmail.com> - 2013-06-03 06:28 +1000
Re: PyWart: The problem with "print" Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-03 18:37 -0700
Re: PyWart: The problem with "print" Vito De Tullio <vito.detullio@gmail.com> - 2013-06-04 05:16 +0200
Re: PyWart: The problem with "print" Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-03 20:53 -0700
Re: PyWart: The problem with "print" Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-04 04:30 +0000
Bools and explicitness [was Re: PyWart: The problem with "print"] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-04 05:39 +0000
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-04 08:44 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Chris Angelico <rosuav@gmail.com> - 2013-06-05 02:00 +1000
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-04 09:19 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Chris Angelico <rosuav@gmail.com> - 2013-06-05 02:27 +1000
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-05 05:28 +0000
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] alex23 <wuwei23@gmail.com> - 2013-06-04 22:31 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Ned Batchelder <ned@nedbatchelder.com> - 2013-06-04 13:25 -0400
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-04 09:09 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] alex23 <wuwei23@gmail.com> - 2013-06-04 18:31 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Fábio Santos <fabiosantosart@gmail.com> - 2013-06-04 17:10 +0100
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Jason Swails <jason.swails@gmail.com> - 2013-06-04 13:32 -0400
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-04 11:42 -0600
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-04 16:21 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-06-05 00:37 +0100
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Michael Torrie <torriem@gmail.com> - 2013-06-04 23:28 -0600
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] "Russ P." <Russ.Paielli@gmail.com> - 2013-06-04 23:11 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Chris Angelico <rosuav@gmail.com> - 2013-06-05 17:15 +1000
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] "Russ P." <Russ.Paielli@gmail.com> - 2013-06-05 00:47 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-06 09:49 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Chris Angelico <rosuav@gmail.com> - 2013-06-07 02:59 +1000
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Dan Stromberg <drsalists@gmail.com> - 2013-06-06 18:26 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-06-05 09:59 +0100
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] "Russ P." <Russ.Paielli@gmail.com> - 2013-06-05 09:15 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Chris Angelico <rosuav@gmail.com> - 2013-06-06 02:59 +1000
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] "Russ P." <Russ.Paielli@gmail.com> - 2013-06-05 14:59 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-06 01:56 +0000
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Chris Angelico <rosuav@gmail.com> - 2013-06-06 12:29 +1000
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] "Russ P." <Russ.Paielli@gmail.com> - 2013-06-05 21:25 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-06 00:06 -0600
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-06 09:29 +0000
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Chris Angelico <rosuav@gmail.com> - 2013-06-06 19:45 +1000
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Serhiy Storchaka <storchaka@gmail.com> - 2013-06-06 14:12 +0300
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Robert Kern <robert.kern@gmail.com> - 2013-06-06 16:35 +0100
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Chris Angelico <rosuav@gmail.com> - 2013-06-07 01:41 +1000
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Robert Kern <robert.kern@gmail.com> - 2013-06-06 17:08 +0100
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] rusi <rustompmody@gmail.com> - 2013-06-06 10:27 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Devin Jeanpierre <jeanpierreda@gmail.com> - 2013-06-06 14:44 -0400
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Mark Janssen <dreamingforward@gmail.com> - 2013-06-06 10:59 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] alex23 <wuwei23@gmail.com> - 2013-06-06 17:53 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Mark Janssen <dreamingforward@gmail.com> - 2013-06-06 18:44 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] alex23 <wuwei23@gmail.com> - 2013-06-06 19:03 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Mark Janssen <dreamingforward@gmail.com> - 2013-06-06 22:01 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-07 02:29 +0000
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Mark Janssen <dreamingforward@gmail.com> - 2013-06-06 20:14 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] rusi <rustompmody@gmail.com> - 2013-06-06 20:24 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Mark Janssen <dreamingforward@gmail.com> - 2013-06-06 20:30 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] rusi <rustompmody@gmail.com> - 2013-06-06 20:43 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] "Russ P." <Russ.Paielli@gmail.com> - 2013-06-06 11:08 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-06 08:49 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Chris Angelico <rosuav@gmail.com> - 2013-06-07 02:00 +1000
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Grant Edwards <invalid@invalid.invalid> - 2013-06-06 17:32 +0000
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-06 01:37 +0000
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Chris Angelico <rosuav@gmail.com> - 2013-06-06 11:45 +1000
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] rusi <rustompmody@gmail.com> - 2013-06-06 07:09 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Chris Angelico <rosuav@gmail.com> - 2013-06-07 01:26 +1000
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] rusi <rustompmody@gmail.com> - 2013-06-06 08:36 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Chris Angelico <rosuav@gmail.com> - 2013-06-07 01:46 +1000
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-06 11:03 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-06 11:11 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Terry Jan Reedy <tjreedy@udel.edu> - 2013-06-05 12:10 -0400
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Michael Torrie <torriem@gmail.com> - 2013-06-05 17:18 -0600
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] "Russ P." <Russ.Paielli@gmail.com> - 2013-06-05 16:52 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Michael Torrie <torriem@gmail.com> - 2013-06-05 19:20 -0600
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-06 09:24 -0700
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] Devin Jeanpierre <jeanpierreda@gmail.com> - 2013-06-06 12:39 -0400
Re: Bools and explicitness [was Re: PyWart: The problem with "print"] alex23 <wuwei23@gmail.com> - 2013-06-06 17:55 -0700
Re: PyWart: The problem with "print" Chris Angelico <rosuav@gmail.com> - 2013-06-04 17:30 +1000
Re: PyWart: The problem with "print" Jason Swails <jason.swails@gmail.com> - 2013-06-02 20:16 -0400
Re: PyWart: The problem with "print" Dan Sommers <dan@tombstonezero.net> - 2013-06-03 03:10 +0000
Re: PyWart: The problem with "print" Jason Swails <jason.swails@gmail.com> - 2013-06-02 23:23 -0400
Re: PyWart: The problem with "print" Dan Sommers <dan@tombstonezero.net> - 2013-06-03 04:20 +0000
Re: PyWart: The problem with "print" Robert Kern <robert.kern@gmail.com> - 2013-06-03 11:52 +0100
Re: PyWart: The problem with "print" Tim Delaney <timothy.c.delaney@gmail.com> - 2013-06-03 13:37 +1000
Python Heisenbugs? (was: Re: PyWart: The problem with "print") Dan Sommers <dan@tombstonezero.net> - 2013-06-03 04:34 +0000
Re: Python Heisenbugs? (was: Re: PyWart: The problem with "print") Chris Angelico <rosuav@gmail.com> - 2013-06-03 15:05 +1000
Re: Python Heisenbugs? (was: Re: PyWart: The problem with "print") Devin Jeanpierre <jeanpierreda@gmail.com> - 2013-06-03 03:06 -0400
Re: PyWart: The problem with "print" Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-06-03 09:49 +0100
Re: PyWart: The problem with "print" Dave Angel <davea@davea.name> - 2013-06-03 08:56 -0400
Re: PyWart: The problem with "print" Chris Angelico <rosuav@gmail.com> - 2013-06-03 12:02 +1000
Re: PyWart: The problem with "print" Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-03 11:12 -0600
Re: PyWart: The problem with "print" Jason Swails <jason.swails@gmail.com> - 2013-06-03 15:09 -0400
Re: PyWart: The problem with "print" Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-03 20:31 +0000
Re: PyWart: The problem with "print" Chris Angelico <rosuav@gmail.com> - 2013-06-04 06:44 +1000
Re: PyWart: The problem with "print" Jason Swails <jason.swails@gmail.com> - 2013-06-03 15:10 -0400
Re: PyWart: The problem with "print" Jason Swails <jason.swails@gmail.com> - 2013-06-03 15:11 -0400
Page 3 of 6 — ← Prev page 1 2 [3] 4 5 6 Next page →
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-06-05 17:15 +1000 |
| Subject | Re: Bools and explicitness [was Re: PyWart: The problem with "print"] |
| Message-ID | <mailman.2704.1370416560.3114.python-list@python.org> |
| In reply to | #47026 |
On Wed, Jun 5, 2013 at 4:11 PM, Russ P. <Russ.Paielli@gmail.com> wrote:
> On Tuesday, June 4, 2013 8:44:11 AM UTC-7, Rick Johnson wrote:
>
>> Yes, but the problem is not "my approach", rather the lack
>>
>> of proper language design (my apologizes to the "anointed
>>
>> one". ;-)
>
> If you don't like implicit conversion to Boolean, then maybe you should be using another language -- and I mean that in a constructive sense. I'm not particularly fond of it either, but I switched from Python to another language a while back. The issue is not a lack of "proper language design" but rather a language design philosophy that values conciseness and simplicity over explicitness and rigor.
(Out of curiosity, which language? Feel free to not answer, or to
answer off-list, as that's probably not constructive to the thread.)
I cannot name a single modern programming language that does NOT have
some kind of implicit boolification. The only such language I know of
is REXX, which has a single data type for everything, but insists on
the exact strings "1" and "0" for True and False, anything else is an
error. Every other language has some definition of "these things are
true, these are false"; for instance:
* C-family languages treat all nonzero integers as true
* Shells treat 0 as "success" and nonzero as "error", and therefore as
"true" and "false" respectively (yes, this IS an inversion)
* Pike allows any variable to contain the integer 0, regardless of its
declared type, and thus is a sort of "null" value which is false; all
strings, arrays, mappings, etc are true
* Python treats an empty "thing" as false and a nonempty one as true
SQL is like REXX in that it's fairly strict; a condition must be a
boolean (example from PostgreSQL):
rosuav=> select 1+2 where 1;
ERROR: argument of WHERE must be type boolean, not type integer
LINE 1: select 1+2 where 1;
^
But an explicit conversion is permitted:
rosuav=> select 1+2 where cast (5 as boolean);
?column?
----------
3
(1 row)
> It's all loosey goosey -- which is fine for many applications but certainly not for critical ones.
The looseness doesn't preclude critical applications. It's all a
question of what you're testing. Does your code care that this be a
list, and not something else? Then test! You have that option. What
happens if it isn't a list, and something is done that bombs with an
exception? Maybe that's not a problem.
Critical applications can often be built in layers. For instance, a
network server might listen for multiple socket connections, and for
each connection, process multiple requests. You would want to catch
exceptions at the two boundaries there; if a request handler crashes,
the connection should not be dropped, and if a connection handler
crashes, the server should keep running. With some basic defenses like
that, your code need no longer concern itself with trivialities - if
something goes wrong, there'll be an exception in the log. (BTW, this
is one of the places where a bare or very wide except clause is
appropriate. Log and move on.)
ChrisA
[toc] | [prev] | [next] | [standalone]
| From | "Russ P." <Russ.Paielli@gmail.com> |
|---|---|
| Date | 2013-06-05 00:47 -0700 |
| Subject | Re: Bools and explicitness [was Re: PyWart: The problem with "print"] |
| Message-ID | <bc080fe5-b4ee-47e6-a526-8887654f4e34@googlegroups.com> |
| In reply to | #47029 |
On Wednesday, June 5, 2013 12:15:57 AM UTC-7, Chris Angelico wrote: > On Wed, Jun 5, 2013 at 4:11 PM, Russ P. wrote: > > > On Tuesday, June 4, 2013 8:44:11 AM UTC-7, Rick Johnson wrote: > > > > > >> Yes, but the problem is not "my approach", rather the lack > > >> > > >> of proper language design (my apologizes to the "anointed > > >> > > >> one". ;-) > > > > > > If you don't like implicit conversion to Boolean, then maybe you should be using another language -- and I mean that in a constructive sense. I'm not particularly fond of it either, but I switched from Python to another language a while back. The issue is not a lack of "proper language design" but rather a language design philosophy that values conciseness and simplicity over explicitness and rigor. > > > > (Out of curiosity, which language? Feel free to not answer, or to > > answer off-list, as that's probably not constructive to the thread.) No problem. I'm using Scala. It has a sophisticated type system. The language is not perfect, but it seems to suit my needs fairly well. > > > I cannot name a single modern programming language that does NOT have > > some kind of implicit boolification. The only such language I know of > > is REXX, which has a single data type for everything, but insists on > > the exact strings "1" and "0" for True and False, anything else is an > > error. Every other language has some definition of "these things are > > true, these are false"; for instance: Scala (and Java) don't do that. Nor does Ada. That's because Ada is designed for no-nonsense critical systems. It is the standard higher-order language for flight control systems, for example. > > It's all loosey goosey -- which is fine for many applications but certainly not for critical ones. > > > > The looseness doesn't preclude critical applications. It's all a > > question of what you're testing. Does your code care that this be a > > list, and not something else? Then test! You have that option. What > > happens if it isn't a list, and something is done that bombs with an > > exception? Maybe that's not a problem. > > > > Critical applications can often be built in layers. For instance, a > > network server might listen for multiple socket connections, and for > > each connection, process multiple requests. You would want to catch > > exceptions at the two boundaries there; if a request handler crashes, > > the connection should not be dropped, and if a connection handler > > crashes, the server should keep running. With some basic defenses like > > that, your code need no longer concern itself with trivialities - if > > something goes wrong, there'll be an exception in the log. (BTW, this > > is one of the places where a bare or very wide except clause is > > appropriate. Log and move on.) Well, I don't really want to open the Pandora's box of static vs. dynamic typing. Yes, with enough testing, I'm sure you can get something good out of a dynamically typed language for small to medium-sized applications, but I have my doubts about larger applications. However, I don't claim to be an expert. Someone somewhere has probably developed a solid large application in Python. But I'll bet a dollar to a dime that it took more work than it would have taken in a good statically typed language. Yes, extensive testing can go a long way, but extensive testing combined with good static typing can go even further for the same level of effort.
[toc] | [prev] | [next] | [standalone]
| From | Rick Johnson <rantingrickjohnson@gmail.com> |
|---|---|
| Date | 2013-06-06 09:49 -0700 |
| Subject | Re: Bools and explicitness [was Re: PyWart: The problem with "print"] |
| Message-ID | <7127916f-7d8a-418b-bda1-595e5bde8cbd@googlegroups.com> |
| In reply to | #47029 |
On Wednesday, June 5, 2013 2:15:57 AM UTC-5, Chris Angelico wrote: > [...] > I cannot name a single modern programming language that does NOT have > some kind of implicit boolification. Congrats: Again you join the ranks of most children who make excuses for their foolish actions along the lines of: "Hey, they did it first!" Well, the lemmings get what they deserve i suppose.
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-06-07 02:59 +1000 |
| Subject | Re: Bools and explicitness [was Re: PyWart: The problem with "print"] |
| Message-ID | <mailman.2816.1370537956.3114.python-list@python.org> |
| In reply to | #47244 |
On Fri, Jun 7, 2013 at 2:49 AM, Rick Johnson <rantingrickjohnson@gmail.com> wrote: > On Wednesday, June 5, 2013 2:15:57 AM UTC-5, Chris Angelico wrote: >> [...] >> I cannot name a single modern programming language that does NOT have >> some kind of implicit boolification. > > Congrats: Again you join the ranks of most children who make excuses for their foolish actions along the lines of: > > "Hey, they did it first!" > > Well, the lemmings get what they deserve i suppose. You say that like it's a bad thing. http://www.catb.org/jargon/html/E/ELIZA-effect.html ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Dan Stromberg <drsalists@gmail.com> |
|---|---|
| Date | 2013-06-06 18:26 -0700 |
| Subject | Re: Bools and explicitness [was Re: PyWart: The problem with "print"] |
| Message-ID | <mailman.2834.1370568369.3114.python-list@python.org> |
| In reply to | #47244 |
[Multipart message — attachments visible in raw view] — view raw
On Thu, Jun 6, 2013 at 9:49 AM, Rick Johnson <rantingrickjohnson@gmail.com>wrote: > Congrats: Again you join the ranks of most children who make excuses for > their foolish actions along the lines of: > > "Hey, they did it first!" > > Well, the lemmings get what they deserve i suppose. > Lemmings don't really jump off cliffs. The Disney film documenting it was staged by a film crew who'd -heard- Lemmings did, and forced the little guys over a cliff in the name of saving time. http://en.wikipedia.org/wiki/Lemming
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2013-06-05 09:59 +0100 |
| Subject | Re: Bools and explicitness [was Re: PyWart: The problem with "print"] |
| Message-ID | <mailman.2708.1370422741.3114.python-list@python.org> |
| In reply to | #47026 |
On 05/06/2013 07:11, Russ P. wrote: > But then, what would you expect of a language that allows you to write > > x = 1 > x = "Hello" > > It's all loosey goosey -- which is fine for many applications but certainly not for critical ones. > I want to launch this rocket with an expensive satellite on top. I know it's safe as the code is written in ADA. Whoops :( -- "Steve is going for the pink ball - and for those of you who are watching in black and white, the pink is next to the green." Snooker commentator 'Whispering' Ted Lowe. Mark Lawrence
[toc] | [prev] | [next] | [standalone]
| From | "Russ P." <Russ.Paielli@gmail.com> |
|---|---|
| Date | 2013-06-05 09:15 -0700 |
| Subject | Re: Bools and explicitness [was Re: PyWart: The problem with "print"] |
| Message-ID | <31ca14e1-973d-44e6-886c-011a55755d76@googlegroups.com> |
| In reply to | #47038 |
On Wednesday, June 5, 2013 1:59:01 AM UTC-7, Mark Lawrence wrote: > On 05/06/2013 07:11, Russ P. wrote: > > > > > But then, what would you expect of a language that allows you to write > > > > > > x = 1 > > > x = "Hello" > > > > > > It's all loosey goosey -- which is fine for many applications but certainly not for critical ones. > > > > > > > I want to launch this rocket with an expensive satellite on top. I know > > it's safe as the code is written in ADA. Whoops :( So Python would have been a better choice? Yeah, right. If you know anything about that rocket mishap, you should know that Ada was not the source of the problem. Ada won't keep airplane wings from breaking either, by the way. It's not magic.
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-06-06 02:59 +1000 |
| Subject | Re: Bools and explicitness [was Re: PyWart: The problem with "print"] |
| Message-ID | <mailman.2747.1370451556.3114.python-list@python.org> |
| In reply to | #47101 |
On Thu, Jun 6, 2013 at 2:15 AM, Russ P. <Russ.Paielli@gmail.com> wrote: > On Wednesday, June 5, 2013 1:59:01 AM UTC-7, Mark Lawrence wrote: >> I want to launch this rocket with an expensive satellite on top. I know >> >> it's safe as the code is written in ADA. Whoops :( > > > So Python would have been a better choice? Yeah, right. If you know anything about that rocket mishap, you should know that Ada was not the source of the problem. Ada won't keep airplane wings from breaking either, by the way. It's not magic. Frankly, I don't think the language much matters. It's all down to the skill of the programmers and testers. Ada wasn't the source of the problem unless Ada has a bug in it... which is going to be true of pretty much any language. Maybe Python would be a better choice, maybe not; but let me tell you this, if the choice of language means the difference between testable in three months and testable code in three years, I'm going for the former. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | "Russ P." <Russ.Paielli@gmail.com> |
|---|---|
| Date | 2013-06-05 14:59 -0700 |
| Subject | Re: Bools and explicitness [was Re: PyWart: The problem with "print"] |
| Message-ID | <96cd7a31-40ce-4e51-9489-446b7f002a0e@googlegroups.com> |
| In reply to | #47112 |
On Wednesday, June 5, 2013 9:59:07 AM UTC-7, Chris Angelico wrote: > On Thu, Jun 6, 2013 at 2:15 AM, Russ P. wrote: > > > On Wednesday, June 5, 2013 1:59:01 AM UTC-7, Mark Lawrence wrote: > > >> I want to launch this rocket with an expensive satellite on top. I know > > >> > > >> it's safe as the code is written in ADA. Whoops :( > > > > > > > > > So Python would have been a better choice? Yeah, right. If you know anything about that rocket mishap, you should know that Ada was not the source of the problem. Ada won't keep airplane wings from breaking either, by the way. It's not magic. > > > > Frankly, I don't think the language much matters. It's all down to the > > skill of the programmers and testers. Ada wasn't the source of the > > problem unless Ada has a bug in it... which is going to be true of > > pretty much any language. Maybe Python would be a better choice, maybe > > not; but let me tell you this, if the choice of language means the > > difference between testable in three months and testable code in three > > years, I'm going for the former. > > > > ChrisA I'm not an Ada guy, but Ada advocates claim that it reduces development time by half in the long run compared to C and C++ due to reduced debugging time and simpler maintenance. Then again, I think Java people make a similar claim. As for Python, my experience with it is that, as your application grows, you start getting confused about what the argument types are or are supposed to be. That requires the developer to keep much more of the design in his head, and that undesirable. Of course, you can always put the argument types in comments, but that won't be verified by the compiler.
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2013-06-06 01:56 +0000 |
| Subject | Re: Bools and explicitness [was Re: PyWart: The problem with "print"] |
| Message-ID | <51afec46$0$29966$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #47153 |
On Wed, 05 Jun 2013 14:59:31 -0700, Russ P. wrote: > I'm not an Ada guy, but Ada advocates claim that it reduces development > time by half in the long run compared to C and C++ due to reduced > debugging time and simpler maintenance. They may be right. Far too many people think that C and C++ are "best of breed" in static languages. They aren't. > Then again, I think Java people make a similar claim. Java people would take credit for the sun coming up if they could :-) > As for Python, my experience with it is that, as > your application grows, you start getting confused about what the > argument types are or are supposed to be. Whereas people never get confused about the arguments in static typed languages? The only difference is whether the compiler tells you that you've passed the wrong type, or your unit test tells you that you've passed the wrong type. What, you don't have unit tests? Then how do you know that the code does the right thing when passed data of the right type? Adding an extra couple of unit tests is not that big a burden. Of course, if there was a way to automate that, why wouldn't you take advantage of it? Python currently has no standard way of doing such automated type tests, and probably won't ever get one. A static typed language gives you those tests for free, but in many languages at the cost that you probably end up spending more time fighting to satisfy the compiler than you save by not writing unit tests. -- Steven
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-06-06 12:29 +1000 |
| Subject | Re: Bools and explicitness [was Re: PyWart: The problem with "print"] |
| Message-ID | <mailman.2783.1370485793.3114.python-list@python.org> |
| In reply to | #47176 |
On Thu, Jun 6, 2013 at 11:56 AM, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: > On Wed, 05 Jun 2013 14:59:31 -0700, Russ P. wrote: >> As for Python, my experience with it is that, as >> your application grows, you start getting confused about what the >> argument types are or are supposed to be. > > Whereas people never get confused about the arguments in static typed > languages? > > The only difference is whether the compiler tells you that you've passed > the wrong type, or your unit test tells you that you've passed the wrong > type. What, you don't have unit tests? Then how do you know that the code > does the right thing when passed data of the right type? Adding an extra > couple of unit tests is not that big a burden. The valid type(s) for an argument can be divided into two categories: Those the compiler can check for, and those the compiler can't check for. Some languages have more in the first category than others, but what compiler can prove that a string is an HTML-special-characters-escaped string? In a very few languages, the compiler can insist that an integer be between 7 and 30, but there'll always be some things you can't demonstrate with a function signature. That said, though, I do like being able to make at least *some* declaration there. It helps catch certain types of error. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | "Russ P." <Russ.Paielli@gmail.com> |
|---|---|
| Date | 2013-06-05 21:25 -0700 |
| Subject | Re: Bools and explicitness [was Re: PyWart: The problem with "print"] |
| Message-ID | <6ec93870-7178-47b9-b509-38d8639735ed@googlegroups.com> |
| In reply to | #47179 |
On Wednesday, June 5, 2013 7:29:44 PM UTC-7, Chris Angelico wrote: > On Thu, Jun 6, 2013 at 11:56 AM, Steven D'Aprano > > <steve+comp.lang.python@pearwood.info> wrote: > > > On Wed, 05 Jun 2013 14:59:31 -0700, Russ P. wrote: > > >> As for Python, my experience with it is that, as > > >> your application grows, you start getting confused about what the > > >> argument types are or are supposed to be. > > > > > > Whereas people never get confused about the arguments in static typed > > > languages? > > > > > > The only difference is whether the compiler tells you that you've passed > > > the wrong type, or your unit test tells you that you've passed the wrong > > > type. What, you don't have unit tests? Then how do you know that the code > > > does the right thing when passed data of the right type? Adding an extra > > > couple of unit tests is not that big a burden. > > > > The valid type(s) for an argument can be divided into two categories: > > Those the compiler can check for, and those the compiler can't check > > for. Some languages have more in the first category than others, but > > what compiler can prove that a string is an > > HTML-special-characters-escaped string? In a very few languages, the > > compiler can insist that an integer be between 7 and 30, but there'll > > always be some things you can't demonstrate with a function signature. > > > > That said, though, I do like being able to make at least *some* > > declaration there. It helps catch certain types of error. I recall reading a few years ago that Guido was thinking about adding optional type annotations. I don't know if that went anywhere or not, but I thought it was a good idea. Eventually I got tired of waiting, and I realized that I just wanted a statically typed language, so I started using one. Steven's view on static vs. dynamic typing are interesting, but I think they are "out of the mainstream," for whatever that's worth. Does that mean he is wrong? I don't know. But I do know that statically typed code just seems to me to fit together tighter and more solidly. Maybe it's a liberal/conservative thing. Do liberals tend to favor dynamic typing?
[toc] | [prev] | [next] | [standalone]
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2013-06-06 00:06 -0600 |
| Subject | Re: Bools and explicitness [was Re: PyWart: The problem with "print"] |
| Message-ID | <mailman.2785.1370498830.3114.python-list@python.org> |
| In reply to | #47187 |
On Wed, Jun 5, 2013 at 10:25 PM, Russ P. <Russ.Paielli@gmail.com> wrote: > I recall reading a few years ago that Guido was thinking about adding optional type annotations. I don't know if that went anywhere or not, but I thought it was a good idea. Eventually I got tired of waiting, and I realized that I just wanted a statically typed language, so I started using one. Python 3 has support for arbitrary function argument annotations. The language itself ascribes no special meaning to it, so it's up to the user to add a type-checker (or whatever else they might want to use it for).
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2013-06-06 09:29 +0000 |
| Subject | Re: Bools and explicitness [was Re: PyWart: The problem with "print"] |
| Message-ID | <51b0565d$0$11118$c3e8da3@news.astraweb.com> |
| In reply to | #47179 |
On Thu, 06 Jun 2013 12:29:44 +1000, Chris Angelico wrote:
> On Thu, Jun 6, 2013 at 11:56 AM, Steven D'Aprano
> <steve+comp.lang.python@pearwood.info> wrote:
>> On Wed, 05 Jun 2013 14:59:31 -0700, Russ P. wrote:
>>> As for Python, my experience with it is that, as your application
>>> grows, you start getting confused about what the argument types are or
>>> are supposed to be.
>>
>> Whereas people never get confused about the arguments in static typed
>> languages?
>>
>> The only difference is whether the compiler tells you that you've
>> passed the wrong type, or your unit test tells you that you've passed
>> the wrong type. What, you don't have unit tests? Then how do you know
>> that the code does the right thing when passed data of the right type?
>> Adding an extra couple of unit tests is not that big a burden.
>
> The valid type(s) for an argument can be divided into two categories:
> Those the compiler can check for, and those the compiler can't check
> for. Some languages have more in the first category than others, but
> what compiler can prove that a string is an
> HTML-special-characters-escaped string? In a very few languages, the
> compiler can insist that an integer be between 7 and 30, but there'll
> always be some things you can't demonstrate with a function signature.
>
> That said, though, I do like being able to make at least *some*
> declaration there. It helps catch certain types of error.
*shrug*
I don't terribly miss type declarations. Function argument declarations
are a bit simpler in Pascal, compared to Python:
Function Add(A, B : Integer) : Integer;
Begin
Add := A + B;
End;
versus
def add(a, b):
if not (isinstance(a, int) and isinstance(b, int)):
raise TypeError
return a + b
but not that much simpler. And while Python can trivially support
multiple types, Pascal cannot. (Some other static typed languages may.)
Whatever benefit there is in declaring the type of a function is lost due
to the inability to duck-type or program to an interface. There's no type
that says "any object with a 'next' method", for example. And having to
declare local variables is a PITA with little benefit.
Give me a language with type inference, and a nice, easy way to keep duck-
typing, and I'll reconsider. But until then, I don't believe the benefit
of static types comes even close to paying for the extra effort.
--
Steven
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-06-06 19:45 +1000 |
| Subject | Re: Bools and explicitness [was Re: PyWart: The problem with "print"] |
| Message-ID | <mailman.2790.1370511951.3114.python-list@python.org> |
| In reply to | #47200 |
On Thu, Jun 6, 2013 at 7:29 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> Whatever benefit there is in declaring the type of a function is lost due
> to the inability to duck-type or program to an interface. There's no type
> that says "any object with a 'next' method", for example. And having to
> declare local variables is a PITA with little benefit.
>
> Give me a language with type inference, and a nice, easy way to keep duck-
> typing, and I'll reconsider. But until then, I don't believe the benefit
> of static types comes even close to paying for the extra effort.
Here are some classic ways to do the multiple-types-accepted option.
//C++ style: overloading
int max(int a,int b) {return a>b ? a : b;}
float max(float a,float b) {return a>b ? a : b;}
//C++ also lets you go for templates, but leave that aside
//Pike style: piped types
int|float max(int|float a,int|float b) {return a>b ? a : b;}
//This lets you write one lot of code but doesn't let
//you declare that both args must be the same type
# Python style: accept anything, then (maybe) check
def max(a,b): return a if a>b else b
//Pike does this too:
mixed max(mixed a,mixed b) {return a>b ? a : b;}
/* So does C, but only with pointers: */
void *max(void *a,void *b) {... uhh, this is nontrivial actually ...}
For the "accept any object that has a next() method" sorts of rules, I
don't know of any really viable system that does that usefully. The
concept of implementing interfaces in Java comes close, but the class
author has to declare that it's implementing some named interface. In
theory there could be something that deduces the validity from the
given structure, but I'm not aware of any language that does this. But
it would let you do stuff like this (prototyped in Python):
class Integers:
def __init__(self): self.value=0
def next(self):
self.value+=1
return self.value
interface Iterable:
next(self)
def grab_three_values(Iterable iter):
return iter.next(),iter.next(),iter.next()
With a language that checks these sorts of things at compile time,
it's not a big deal to test. With something fully dynamic like Python,
it's probably not worth the effort. But maybe checks like this could
be useful to something like Coverity.
ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Serhiy Storchaka <storchaka@gmail.com> |
|---|---|
| Date | 2013-06-06 14:12 +0300 |
| Subject | Re: Bools and explicitness [was Re: PyWart: The problem with "print"] |
| Message-ID | <mailman.2796.1370517152.3114.python-list@python.org> |
| In reply to | #47200 |
06.06.13 12:45, Chris Angelico написав(ла): > For the "accept any object that has a next() method" sorts of rules, I > don't know of any really viable system that does that usefully. The > concept of implementing interfaces in Java comes close, but the class > author has to declare that it's implementing some named interface. In > theory there could be something that deduces the validity from the > given structure, but I'm not aware of any language that does this. Go?
[toc] | [prev] | [next] | [standalone]
| From | Robert Kern <robert.kern@gmail.com> |
|---|---|
| Date | 2013-06-06 16:35 +0100 |
| Subject | Re: Bools and explicitness [was Re: PyWart: The problem with "print"] |
| Message-ID | <mailman.2807.1370532929.3114.python-list@python.org> |
| In reply to | #47200 |
On 2013-06-06 10:45, Chris Angelico wrote: > For the "accept any object that has a next() method" sorts of rules, I > don't know of any really viable system that does that usefully. The > concept of implementing interfaces in Java comes close, but the class > author has to declare that it's implementing some named interface. In > theory there could be something that deduces the validity from the > given structure, but I'm not aware of any language that does this. But > it would let you do stuff like this (prototyped in Python): > > class Integers: > def __init__(self): self.value=0 > def next(self): > self.value+=1 > return self.value > > interface Iterable: > next(self) > > def grab_three_values(Iterable iter): > return iter.next(),iter.next(),iter.next() > > With a language that checks these sorts of things at compile time, > it's not a big deal to test. With something fully dynamic like Python, > it's probably not worth the effort. But maybe checks like this could > be useful to something like Coverity. As Serhiy notes, Go does this, almost exactly as you wrote it (modulo syntax). http://golang.org/doc/effective_go.html#interfaces_and_types -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-06-07 01:41 +1000 |
| Subject | Re: Bools and explicitness [was Re: PyWart: The problem with "print"] |
| Message-ID | <mailman.2810.1370533633.3114.python-list@python.org> |
| In reply to | #47200 |
On Fri, Jun 7, 2013 at 1:35 AM, Robert Kern <robert.kern@gmail.com> wrote: > On 2013-06-06 10:45, Chris Angelico wrote: > >> For the "accept any object that has a next() method" sorts of rules, I >> don't know of any really viable system that does that usefully. The >> concept of implementing interfaces in Java comes close, but the class >> author has to declare that it's implementing some named interface. In >> theory there could be something that deduces the validity from the >> given structure, but I'm not aware of any language that does this. But >> it would let you do stuff like this (prototyped in Python): > > > As Serhiy notes, Go does this, almost exactly as you wrote it (modulo > syntax). > > http://golang.org/doc/effective_go.html#interfaces_and_types Thanks (and thanks for actually providing a link). Many years ago I came to the conclusion that anything I could conceive in language design has already been done somewhere :) Anyway, regardless of your language, there's always some criteria that can't be coded. Suppose the valid input for a function were "integers whose square roots are integers but whose cube roots are not". You won't easily get compile-time checking of that. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Robert Kern <robert.kern@gmail.com> |
|---|---|
| Date | 2013-06-06 17:08 +0100 |
| Subject | Re: Bools and explicitness [was Re: PyWart: The problem with "print"] |
| Message-ID | <mailman.2814.1370534922.3114.python-list@python.org> |
| In reply to | #47200 |
On 2013-06-06 16:41, Chris Angelico wrote: > Anyway, regardless of your language, there's always some criteria that > can't be coded. Suppose the valid input for a function were "integers > whose square roots are integers but whose cube roots are not". You > won't easily get compile-time checking of that. Say that on a Haskell list, and they'll take it as a challenge. :-) -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
[toc] | [prev] | [next] | [standalone]
| From | rusi <rustompmody@gmail.com> |
|---|---|
| Date | 2013-06-06 10:27 -0700 |
| Subject | Re: Bools and explicitness [was Re: PyWart: The problem with "print"] |
| Message-ID | <57582781-3bc1-4ec5-a8b9-485453a89105@a9g2000pbq.googlegroups.com> |
| In reply to | #47240 |
On Jun 6, 9:08 pm, Robert Kern <robert.k...@gmail.com> wrote: > On 2013-06-06 16:41, Chris Angelico wrote: > > > Anyway, regardless of your language, there's always some criteria that > > can't be coded. Suppose the valid input for a function were "integers > > whose square roots are integers but whose cube roots are not". You > > won't easily get compile-time checking of that. > > Say that on a Haskell list, and they'll take it as a challenge. :-) Yes, all programming communities have blind-spots. The Haskell community's is that Haskell is safe and safe means that errors are caught at compile-time. Unfortunately* the halting problem stands. When generalized to Rice theorem it says that only trivial properties of programs are algorithmically decidable: http://mathworld.wolfram.com/RicesTheorem.html And so the semantic correctness of a program -- a non-trivial property -- is not decidable. In short the Haskell dream is a pipe-dream**. Discussed in more detail here: http://blog.languager.org/2012/08/functional-programming-philosophical.html. Nevertheless I need to say: If a programmers comes to python from Haskell, he will end up being a better programmer than one coming from C or Java or… * actually fortunately considering that for most of us programming is our job :-) ** Haskellers would point out that there is agda which grows out of Haskell and in agda one can encode arbitrary properties of types.
[toc] | [prev] | [next] | [standalone]
Page 3 of 6 — ← Prev page 1 2 [3] 4 5 6 Next page →
Back to top | Article view | comp.lang.python
csiph-web