Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #108830 > unrolled thread

for / while else doesn't make sense

Started byHerkermer Sherwood <theherk@gmail.com>
First post2016-05-19 09:31 -0700
Last post2016-06-16 11:19 +1000
Articles 20 on this page of 282 — 43 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  for / while else doesn't make sense Herkermer Sherwood <theherk@gmail.com> - 2016-05-19 09:31 -0700
    Re: for / while else doesn't make sense Ned Batchelder <ned@nedbatchelder.com> - 2016-05-19 10:22 -0700
      Re: for / while else doesn't make sense Steven D'Aprano <steve@pearwood.info> - 2016-05-20 04:02 +1000
      Re: for / while else doesn't make sense theherk@gmail.com - 2016-05-19 11:47 -0700
        Re: for / while else doesn't make sense Marko Rauhamaa <marko@pacujo.net> - 2016-05-19 23:28 +0300
        Re: for / while else doesn't make sense David Jardine <david@jardine.de> - 2016-05-19 21:49 +0200
    Re: for / while else doesn't make sense Steven D'Aprano <steve@pearwood.info> - 2016-05-20 03:46 +1000
      Re: for / while else doesn't make sense Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-05-19 17:55 +0000
        Re: for / while else doesn't make sense Steven D'Aprano <steve@pearwood.info> - 2016-05-20 10:06 +1000
          Re: for / while else doesn't make sense gst <g.starck@gmail.com> - 2016-05-19 19:02 -0700
            Re: for / while else doesn't make sense Stephen Hansen <me+python@ixokai.io> - 2016-05-19 23:53 -0700
          Re: for / while else doesn't make sense Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-05-20 11:55 +0000
            Re: for / while else doesn't make sense Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-05-20 19:57 -0400
              Re: for / while else doesn't make sense Steven D'Aprano <steve@pearwood.info> - 2016-05-21 21:26 +1000
            Re: for / while else doesn't make sense Ethan Furman <ethan@stoneleaf.us> - 2016-05-20 16:58 -0700
              Re: for / while else doesn't make sense Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-05-21 00:24 +0000
                Re: for / while else doesn't make sense Steven D'Aprano <steve@pearwood.info> - 2016-05-21 13:50 +1000
                  Re: for / while else doesn't make sense Chris Angelico <rosuav@gmail.com> - 2016-05-21 14:01 +1000
                    Re: for / while else doesn't make sense Steven D'Aprano <steve@pearwood.info> - 2016-05-21 19:56 +1000
                      Re: for / while else doesn't make sense Chris Angelico <rosuav@gmail.com> - 2016-05-21 20:08 +1000
                        Re: for / while else doesn't make sense Steven D'Aprano <steve@pearwood.info> - 2016-05-21 20:55 +1000
                          Re: for / while else doesn't make sense Chris Angelico <rosuav@gmail.com> - 2016-05-21 21:10 +1000
          Re: for / while else doesn't make sense Erik <python@lucidity.plus.com> - 2016-05-21 08:20 +0100
            Re: for / while else doesn't make sense Marko Rauhamaa <marko@pacujo.net> - 2016-05-21 11:37 +0300
            Re: for / while else doesn't make sense Steven D'Aprano <steve@pearwood.info> - 2016-05-21 20:39 +1000
              Re: for / while else doesn't make sense Erik <python@lucidity.plus.com> - 2016-05-21 21:48 +0100
                Re: for / while else doesn't make sense Steven D'Aprano <steve@pearwood.info> - 2016-05-22 12:57 +1000
              Re: for / while else doesn't make sense Michael Selik <michael.selik@gmail.com> - 2016-05-22 02:55 +0000
          Re: for / while else doesn't make sense Chris Angelico <rosuav@gmail.com> - 2016-05-21 17:29 +1000
        Re: for / while else doesn't make sense Bob Martin <bob.martin@excite.com> - 2016-05-20 07:45 +0100
      Re: for / while else doesn't make sense Chris Angelico <rosuav@gmail.com> - 2016-05-20 06:01 +1000
      Re: for / while else doesn't make sense Ian Kelly <ian.g.kelly@gmail.com> - 2016-05-19 14:11 -0600
      Re: for / while else doesn't make sense Chris Angelico <rosuav@gmail.com> - 2016-05-20 06:27 +1000
    Re: for / while else doesn't make sense Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-05-20 11:51 +1200
      Re: for / while else doesn't make sense Erik <python@lucidity.plus.com> - 2016-05-20 09:09 +0100
      Re: for / while else doesn't make sense Zachary Ware <zachary.ware+pylist@gmail.com> - 2016-05-20 10:59 -0500
      Re: for / while else doesn't make sense Christopher Reimer <christopher_reimer@icloud.com> - 2016-05-20 12:20 -0700
        Re: for / while else doesn't make sense Steven D'Aprano <steve@pearwood.info> - 2016-05-21 08:43 +1000
          Re: for / while else doesn't make sense theherk@gmail.com - 2016-05-20 16:24 -0700
            Re: for / while else doesn't make sense Marko Rauhamaa <marko@pacujo.net> - 2016-05-21 09:03 +0300
              Re: for / while else doesn't make sense Steven D'Aprano <steve@pearwood.info> - 2016-05-21 21:26 +1000
                Re: for / while else doesn't make sense Ian Kelly <ian.g.kelly@gmail.com> - 2016-05-21 07:51 -0600
                Re: for / while else doesn't make sense Grant Edwards <grant.b.edwards@gmail.com> - 2016-05-21 15:20 +0000
          Re: for / while else doesn't make sense Ben Finney <ben+python@benfinney.id.au> - 2016-05-21 10:21 +1000
          Re: for / while else doesn't make sense Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-05-21 00:35 +0000
            Re: for / while else doesn't make sense Chris Angelico <rosuav@gmail.com> - 2016-05-21 12:05 +1000
              Re: for / while else doesn't make sense Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-05-22 14:15 +0000
                Re: for / while else doesn't make sense Marko Rauhamaa <marko@pacujo.net> - 2016-05-22 17:58 +0300
                  Re: for / while else doesn't make sense Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-05-22 15:09 +0000
                  Re: for / while else doesn't make sense Rustom Mody <rustompmody@gmail.com> - 2016-05-22 08:26 -0700
                  Re: for / while else doesn't make sense Random832 <random832@fastmail.com> - 2016-05-22 13:25 -0400
                    Re: for / while else doesn't make sense Rustom Mody <rustompmody@gmail.com> - 2016-05-22 10:34 -0700
                    Re: for / while else doesn't make sense Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-05-22 18:06 +0000
                      Re: for / while else doesn't make sense Random832 <random832@fastmail.com> - 2016-05-22 14:17 -0400
                    Re: for / while else doesn't make sense Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-05-23 17:09 +1000
                Re: for / while else doesn't make sense Steven D'Aprano <steve@pearwood.info> - 2016-05-23 01:19 +1000
                  Re: for / while else doesn't make sense Chris Angelico <rosuav@gmail.com> - 2016-05-23 01:32 +1000
                    Re: for / while else doesn't make sense Marko Rauhamaa <marko@pacujo.net> - 2016-05-22 18:50 +0300
                  Re: for / while else doesn't make sense Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-05-22 15:52 +0000
                    Re: for / while else doesn't make sense Chris Angelico <rosuav@gmail.com> - 2016-05-23 02:35 +1000
                      Re: for / while else doesn't make sense Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-05-22 16:46 +0000
                        Re: for / while else doesn't make sense Rustom Mody <rustompmody@gmail.com> - 2016-05-22 10:22 -0700
                        Re: for / while else doesn't make sense Random832 <random832@fastmail.com> - 2016-05-22 13:30 -0400
                          Re: for / while else doesn't make sense Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-05-22 17:55 +0000
                            Re: for / while else doesn't make sense Random832 <random832@fastmail.com> - 2016-05-22 14:14 -0400
                            Re: for / while else doesn't make sense Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-05-22 20:51 +0100
                              Re: for / while else doesn't make sense Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-05-23 00:34 +0000
                            Re: for / while else doesn't make sense Ian Kelly <ian.g.kelly@gmail.com> - 2016-05-22 17:04 -0600
                    Re: for / while else doesn't make sense Steven D'Aprano <steve@pearwood.info> - 2016-05-23 08:09 +1000
                      Re: for / while else doesn't make sense Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-05-23 00:36 +0000
                        Re: for / while else doesn't make sense Chris Angelico <rosuav@gmail.com> - 2016-05-23 11:01 +1000
                          Re: for / while else doesn't make sense Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-05-23 01:00 +0000
                            Re: for / while else doesn't make sense breamoreboy@gmail.com - 2016-05-22 18:47 -0700
                              Re: for / while else doesn't make sense Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-05-23 15:35 +0000
                            Re: for / while else doesn't make sense MRAB <python@mrabarnett.plus.com> - 2016-05-23 02:51 +0100
                        Re: for / while else doesn't make sense Ben Finney <ben+python@benfinney.id.au> - 2016-05-23 14:13 +1000
                          Re: for / while else doesn't make sense Rustom Mody <rustompmody@gmail.com> - 2016-05-22 23:09 -0700
                            Re: for / while else doesn't make sense Marko Rauhamaa <marko@pacujo.net> - 2016-05-23 09:30 +0300
                              Re: for / while else doesn't make sense Rustom Mody <rustompmody@gmail.com> - 2016-05-22 23:46 -0700
                            Re: for / while else doesn't make sense Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-05-23 18:09 +1000
                              Re: for / while else doesn't make sense Ian Kelly <ian.g.kelly@gmail.com> - 2016-05-23 08:14 -0600
                                Re: for / while else doesn't make sense Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-05-23 15:29 +0100
                                  Re: for / while else doesn't make sense Ian Kelly <ian.g.kelly@gmail.com> - 2016-05-23 08:49 -0600
                                    Re: for / while else doesn't make sense Pete Forman <petef4+usenet@gmail.com> - 2016-05-23 19:16 +0100
                                      Re: for / while else doesn't make sense Ian Kelly <ian.g.kelly@gmail.com> - 2016-05-23 13:24 -0600
                                        Re: for / while else doesn't make sense Pete Forman <petef4+usenet@gmail.com> - 2016-05-23 22:50 +0100
                                          Re: for / while else doesn't make sense Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-05-24 18:49 +1200
                                            Re: for / while else doesn't make sense Pete Forman <petef4+usenet@gmail.com> - 2016-05-24 19:03 +0100
                                              Re: for / while else doesn't make sense Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-05-25 18:35 +1200
                                      Re: for / while else doesn't make sense Steven D'Aprano <steve@pearwood.info> - 2016-05-24 10:38 +1000
                                  Re: for / while else doesn't make sense Chris Angelico <rosuav@gmail.com> - 2016-05-24 00:57 +1000
                                    Re: for / while else doesn't make sense Steven D'Aprano <steve@pearwood.info> - 2016-05-24 01:47 +1000
                                      Re: for / while else doesn't make sense Chris Angelico <rosuav@gmail.com> - 2016-05-24 01:57 +1000
                                    Re: for / while else doesn't make sense Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-05-23 17:51 +0100
                                      Re: for / while else doesn't make sense Chris Angelico <rosuav@gmail.com> - 2016-05-24 02:59 +1000
                                        Re: for / while else doesn't make sense Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-05-23 20:55 +0100
                                          Re: for / while else doesn't make sense Mark Dickinson <mdickinson@enthought.com> - 2016-05-23 20:17 +0000
                                            Re: for / while else doesn't make sense Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-05-23 22:01 +0100
                                            Numerical methods [was Re: for / while else doesn't make sense] Steven D'Aprano <steve@pearwood.info> - 2016-05-24 10:57 +1000
                                  Re: for / while else doesn't make sense Rustom Mody <rustompmody@gmail.com> - 2016-05-23 08:30 -0700
                                    Re: for / while else doesn't make sense Ian Kelly <ian.g.kelly@gmail.com> - 2016-05-23 10:02 -0600
                                    Re: for / while else doesn't make sense Grant Edwards <grant.b.edwards@gmail.com> - 2016-05-23 20:22 +0000
                                    Re: for / while else doesn't make sense Ian Kelly <ian.g.kelly@gmail.com> - 2016-05-23 09:53 -0600
                                      When were real numbers born? (was for / while else doesn't make sense) Rustom Mody <rustompmody@gmail.com> - 2016-05-23 22:02 -0700
                                    Re: for / while else doesn't make sense Christopher Reimer <christopher_reimer@icloud.com> - 2016-05-23 15:36 -0700
                                      Re: for / while else doesn't make sense Steven D'Aprano <steve@pearwood.info> - 2016-05-24 11:05 +1000
                                        Re: for / while else doesn't make sense Ned Batchelder <ned@nedbatchelder.com> - 2016-05-23 19:19 -0700
                                          META Culture of this place [was Re: for / while else doesn't make sense] Steven D'Aprano <steve@pearwood.info> - 2016-05-25 02:43 +1000
                                            Re: META Culture of this place [was Re: for / while else doesn't make sense] boB Stepp <robertvstepp@gmail.com> - 2016-05-24 12:19 -0500
                                            Re: META Culture of this place [was Re: for / while else doesn't make sense] Ned Batchelder <ned@nedbatchelder.com> - 2016-05-24 10:44 -0700
                                              Re: META Culture of this place [was Re: for / while else doesn't make sense] Paul Rubin <no.email@nospam.invalid> - 2016-05-24 12:54 -0700
                                        Re: for / while else doesn't make sense Grant Edwards <grant.b.edwards@gmail.com> - 2016-05-24 14:23 +0000
                                        Re: for / while else doesn't make sense Christopher Reimer <christopher_reimer@icloud.com> - 2016-05-24 10:40 -0700
                                          Re: for / while else doesn't make sense Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-05-25 18:38 +1200
                                            Extended ASCII [was Re: for / while else doesn't make sense] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-05-25 17:30 +1000
                                            Re: for / while else doesn't make sense Christopher Reimer <christopher_reimer@icloud.com> - 2016-05-25 02:10 -0700
                                              Exended ASCII and code pages [was Re: for / while else doesn't make sense] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-05-25 20:19 +1000
                                                Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense] Chris Angelico <rosuav@gmail.com> - 2016-05-25 20:30 +1000
                                                Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense] Erik <python@lucidity.plus.com> - 2016-05-25 22:03 +0100
                                                  Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense] Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-05-26 10:21 +0300
                                                    Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense] Rustom Mody <rustompmody@gmail.com> - 2016-05-26 00:44 -0700
                                                    Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense] Marko Rauhamaa <marko@pacujo.net> - 2016-05-26 12:11 +0300
                                                      Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense] Chris Angelico <rosuav@gmail.com> - 2016-05-26 19:20 +1000
                                                    Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense] Erik <python@lucidity.plus.com> - 2016-05-26 21:54 +0100
                                                      Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense] Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-05-27 08:03 +0300
                                                Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense] Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-05-25 21:28 -0400
                                                Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense] Erik <python@lucidity.plus.com> - 2016-05-26 09:11 +0100
                                                  Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense] Marko Rauhamaa <marko@pacujo.net> - 2016-05-26 12:20 +0300
                                                    Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense] Erik <python@lucidity.plus.com> - 2016-05-26 21:29 +0100
                                                      Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense] Marko Rauhamaa <marko@pacujo.net> - 2016-05-27 00:12 +0300
                                                        Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense] Steven D'Aprano <steve@pearwood.info> - 2016-05-27 13:35 +1000
                                                          Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense] Marko Rauhamaa <marko@pacujo.net> - 2016-05-27 09:10 +0300
                                                            Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense] Steven D'Aprano <steve@pearwood.info> - 2016-05-27 16:47 +1000
                                                              Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense] Marko Rauhamaa <marko@pacujo.net> - 2016-05-27 10:04 +0300
                                                                Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense] Steven D'Aprano <steve@pearwood.info> - 2016-05-27 19:56 +1000
                                                                  Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense] Random832 <random832@fastmail.com> - 2016-05-27 09:51 -0400
                                                                    Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense] Rustom Mody <rustompmody@gmail.com> - 2016-05-27 08:53 -0700
                                                                      Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense] Random832 <random832@fastmail.com> - 2016-05-27 12:09 -0400
                                                                        Coding systems are political (was Exended ASCII and code pages) Rustom Mody <rustompmody@gmail.com> - 2016-05-27 21:46 -0700
                                                                          Re: Coding systems are political (was Exended ASCII and code pages) wxjmfauth@gmail.com - 2016-05-28 08:16 -0700
                                                                            Re: Coding systems are political (was Exended ASCII and code pages) Ned Batchelder <ned@nedbatchelder.com> - 2016-05-28 08:50 -0700
                                                                          Re: Coding systems are political (was Exended ASCII and code pages) Random832 <random832@fastmail.com> - 2016-05-28 14:05 -0400
                                                                          Re: Coding systems are political (was Exended ASCII and code pages) Steven D'Aprano <steve@pearwood.info> - 2016-05-29 15:37 +1000
                                                                            Re: Coding systems are political (was Exended ASCII and code pages) Rustom Mody <rustompmody@gmail.com> - 2016-05-28 23:12 -0700
                                                                              Re: Coding systems are political (was Exended ASCII and code pages) Terry Reedy <tjreedy@udel.edu> - 2016-05-29 14:46 -0400
                                                                                Re: Coding systems are political (was Exended ASCII and code pages) Christian Gollwitzer <auriocus@gmx.de> - 2016-05-29 22:29 +0200
                                                                                Re: Coding systems are political (was Exended ASCII and code pages) wxjmfauth@gmail.com - 2016-05-30 06:35 -0700
                                                                                Re: Coding systems are political (was Exended ASCII and code pages) Rustom Mody <rustompmody@gmail.com> - 2016-06-04 20:54 -0700
                                                                            Re: Coding systems are political (was Exended ASCII and code pages) alister <alister.ware@ntlworld.com> - 2016-05-29 06:19 +0000
                                                                            Re: Coding systems are political (was Exended ASCII and code pages) Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-05-29 20:54 +1200
                                                                              Re: Coding systems are political (was Exended ASCII and code pages) Marko Rauhamaa <marko@pacujo.net> - 2016-05-29 12:56 +0300
                                                                            Re: Coding systems are political (was Exended ASCII and code pages) wxjmfauth@gmail.com - 2016-05-30 09:11 -0700
                                                                      Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense] Chris Angelico <rosuav@gmail.com> - 2016-05-28 02:16 +1000
                                                                      Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense] Steven D'Aprano <steve@pearwood.info> - 2016-05-28 18:54 +1000
                                                                    Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense] Marko Rauhamaa <marko@pacujo.net> - 2016-05-27 22:03 +0300
                                                                      Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense] Rustom Mody <rustompmody@gmail.com> - 2016-05-27 21:23 -0700
                                                  Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense] Rustom Mody <rustompmody@gmail.com> - 2016-05-26 03:39 -0700
                                                Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense] Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-05-26 07:07 -0400
                                              Re: for / while else doesn't make sense Marko Rauhamaa <marko@pacujo.net> - 2016-05-25 13:47 +0300
                                                Re: for / while else doesn't make sense Christopher Reimer <christopher_reimer@icloud.com> - 2016-05-25 05:19 -0700
                                                Re: for / while else doesn't make sense Rustom Mody <rustompmody@gmail.com> - 2016-05-25 22:49 -0700
                                                  Re: for / while else doesn't make sense Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-05-26 09:54 +0300
                                                    Re: for / while else doesn't make sense Rustom Mody <rustompmody@gmail.com> - 2016-05-26 00:44 -0700
                                                    Re: for / while else doesn't make sense wxjmfauth@gmail.com - 2016-05-26 00:52 -0700
                                                  Re: for / while else doesn't make sense Marko Rauhamaa <marko@pacujo.net> - 2016-05-26 12:05 +0300
                                                    Re: for / while else doesn't make sense Random832 <random832@fastmail.com> - 2016-05-29 14:41 -0400
                                                      Re: for / while else doesn't make sense Marko Rauhamaa <marko@pacujo.net> - 2016-05-29 22:01 +0300
                                    Re: for / while else doesn't make sense Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-05-23 20:07 -0400
                                    Re: for / while else doesn't make sense Chris Angelico <rosuav@gmail.com> - 2016-05-24 10:11 +1000
                                  Re: for / while else doesn't make sense Steven D'Aprano <steve@pearwood.info> - 2016-05-24 02:59 +1000
                                    Re: for / while else doesn't make sense Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-05-23 17:09 +0000
                                      Re: for / while else doesn't make sense Chris Angelico <rosuav@gmail.com> - 2016-05-24 03:33 +1000
                                        Re: for / while else doesn't make sense Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-05-23 17:57 +0000
                                          Re: for / while else doesn't make sense Chris Angelico <rosuav@gmail.com> - 2016-05-24 04:14 +1000
                                      Re: for / while else doesn't make sense Random832 <random832@fastmail.com> - 2016-05-23 13:44 -0400
                                      Re: for / while else doesn't make sense Ian Kelly <ian.g.kelly@gmail.com> - 2016-05-23 11:52 -0600
                                      Re: for / while else doesn't make sense Alan Evangelista <alanoe@linux.vnet.ibm.com> - 2016-05-23 15:06 -0300
                                      Re: for / while else doesn't make sense Steven D'Aprano <steve@pearwood.info> - 2016-05-24 12:15 +1000
                                        Re: for / while else doesn't make sense Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-05-24 10:54 +0000
                                          Re: for / while else doesn't make sense Steven D'Aprano <steve@pearwood.info> - 2016-05-25 03:44 +1000
                                            Re: for / while else doesn't make sense Chris Angelico <rosuav@gmail.com> - 2016-05-25 03:49 +1000
                                            Re: for / while else doesn't make sense MRAB <python@mrabarnett.plus.com> - 2016-05-24 19:57 +0100
                                            Re: for / while else doesn't make sense Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-05-24 20:10 +0000
                                    Re: for / while else doesn't make sense Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-05-23 20:29 +0100
                        Re: for / while else doesn't make sense Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-05-23 18:33 +1000
          Re: for / while else doesn't make sense Grant Edwards <grant.b.edwards@gmail.com> - 2016-05-21 02:17 +0000
          Re: for / while else doesn't make sense Christopher Reimer <christopher_reimer@icloud.com> - 2016-05-20 18:23 -0700
          Re: for / while else doesn't make sense Chris Angelico <rosuav@gmail.com> - 2016-05-21 12:31 +1000
          Re: for / while else doesn't make sense Christopher Reimer <christopher_reimer@icloud.com> - 2016-05-20 20:47 -0700
        Re: for / while else doesn't make sense Rustom Mody <rustompmody@gmail.com> - 2016-05-20 22:18 -0700
          Education [was Re: for / while else doesn't make sense] Steven D'Aprano <steve@pearwood.info> - 2016-05-21 20:05 +1000
            Re: Education [was Re: for / while else doesn't make sense] Christopher Reimer <christopher_reimer@icloud.com> - 2016-05-21 08:51 -0700
              Re: Education [was Re: for / while else doesn't make sense] Marko Rauhamaa <marko@pacujo.net> - 2016-05-21 20:08 +0300
                Re: Education [was Re: for / while else doesn't make sense] Rob Gaddi <rgaddi@highlandtechnology.invalid> - 2016-05-23 16:44 +0000
    Re: for / while else doesn't make sense Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-01 16:39 -0700
      Re: for / while else doesn't make sense Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-06-02 13:44 +1000
      Re: for / while else doesn't make sense Rob Gaddi <rgaddi@highlandtechnology.invalid> - 2016-06-02 20:09 +0000
        Re: for / while else doesn't make sense Ian Kelly <ian.g.kelly@gmail.com> - 2016-06-02 14:46 -0600
        Re: for / while else doesn't make sense BartC <bc@freeuk.com> - 2016-06-02 21:52 +0100
          Re: for / while else doesn't make sense Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-02 18:05 -0700
            Re: for / while else doesn't make sense BartC <bc@freeuk.com> - 2016-06-03 10:23 +0100
          Re: for / while else doesn't make sense Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-02 19:47 -0700
            Re: for / while else doesn't make sense BartC <bc@freeuk.com> - 2016-06-03 10:32 +0100
              Re: for / while else doesn't make sense Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-03 09:22 -0700
                Re: for / while else doesn't make sense Steven D'Aprano <steve@pearwood.info> - 2016-06-04 12:20 +1000
                  Re: for / while else doesn't make sense Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-03 20:41 -0700
                    Re: for / while else doesn't make sense Steven D'Aprano <steve@pearwood.info> - 2016-06-04 19:27 +1000
                      Re: for / while else doesn't make sense Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-04 20:20 -0700
                Re: for / while else doesn't make sense BartC <bc@freeuk.com> - 2016-06-04 13:55 +0100
        Re: for / while else doesn't make sense Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-02 18:08 -0700
          Re: for / while else doesn't make sense Rob Gaddi <rgaddi@highlandtechnology.invalid> - 2016-06-03 15:52 +0000
            Re: for / while else doesn't make sense Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-03 09:24 -0700
              Re: for / while else doesn't make sense Steven D'Aprano <steve@pearwood.info> - 2016-06-04 13:00 +1000
                Re: for / while else doesn't make sense Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-03 20:43 -0700
                  Re: for / while else doesn't make sense Ned Batchelder <ned@nedbatchelder.com> - 2016-06-04 04:37 -0700
                    Re: for / while else doesn't make sense Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-04 20:29 -0700
                      Re: for / while else doesn't make sense Steven D'Aprano <steve@pearwood.info> - 2016-06-05 16:35 +1000
                      Re: for / while else doesn't make sense Ned Batchelder <ned@nedbatchelder.com> - 2016-06-05 04:29 -0700
                        Re: for / while else doesn't make sense Marko Rauhamaa <marko@pacujo.net> - 2016-06-05 14:43 +0300
                          Re: for / while else doesn't make sense Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-06 17:51 -0700
                            Re: for / while else doesn't make sense Dan Sommers <dan@tombstonezero.net> - 2016-06-07 03:34 +0000
                              Re: for / while else doesn't make sense Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-07 00:53 -0700
                                Re: for / while else doesn't make sense Dan Sommers <dan@tombstonezero.net> - 2016-06-07 12:27 +0000
                                  Re: for / while else doesn't make sense Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-07 14:57 -0700
                            Re: for / while else doesn't make sense Ian Kelly <ian.g.kelly@gmail.com> - 2016-06-06 22:35 -0600
                              Re: for / while else doesn't make sense Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-07 00:52 -0700
                                Re: for / while else doesn't make sense Marko Rauhamaa <marko@pacujo.net> - 2016-06-07 11:00 +0300
                                  Re: for / while else doesn't make sense Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-07 15:07 -0700
                                    Re: for / while else doesn't make sense Ned Batchelder <ned@nedbatchelder.com> - 2016-06-07 17:31 -0700
                                      Re: for / while else doesn't make sense Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-07 18:25 -0700
                                      Re: for / while else doesn't make sense Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-07 18:29 -0700
                                        Re: for / while else doesn't make sense Ned Batchelder <ned@nedbatchelder.com> - 2016-06-07 18:40 -0700
                                        Re: for / while else doesn't make sense breamoreboy@gmail.com - 2016-06-07 20:45 -0700
                                    Re: for / while else doesn't make sense Marko Rauhamaa <marko@pacujo.net> - 2016-06-08 08:24 +0300
                                Re: for / while else doesn't make sense Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-06-07 18:36 +1000
                                Re: for / while else doesn't make sense Ian Kelly <ian.g.kelly@gmail.com> - 2016-06-07 05:52 -0600
                                  Re: for / while else doesn't make sense Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-07 14:58 -0700
                                    Re: for / while else doesn't make sense Marko Rauhamaa <marko@pacujo.net> - 2016-06-08 01:06 +0300
                                      Re: for / while else doesn't make sense Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-07 15:08 -0700
                                        Re: for / while else doesn't make sense Marko Rauhamaa <marko@pacujo.net> - 2016-06-08 08:27 +0300
                                          Re: for / while else doesn't make sense Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-08 17:34 -0700
                                            Re: for / while else doesn't make sense Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-06-09 18:19 +1000
                                    Re: for / while else doesn't make sense Ian Kelly <ian.g.kelly@gmail.com> - 2016-06-07 17:11 -0600
                          Re: for / while else doesn't make sense Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-06 17:53 -0700
      Re: for / while else doesn't make sense Ethan Furman <ethan@stoneleaf.us> - 2016-06-07 21:13 -0700
    Re: for / while else doesn't make sense pavlovevidence@gmail.com - 2016-06-12 00:01 -0700
      AttributeError into a bloc try-except AttributeError Vincent Vande Vyvre <vincent.vande.vyvre@telenet.be> - 2016-06-12 09:20 +0200
      Re: AttributeError into a bloc try-except AttributeError Vincent Vande Vyvre <vincent.vande.vyvre@telenet.be> - 2016-06-12 10:30 +0200
      Re: for / while else doesn't make sense Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-06-12 20:06 +1000
        Re: for / while else doesn't make sense Michael Selik <michael.selik@gmail.com> - 2016-06-12 18:44 +0000
          Re: for / while else doesn't make sense Steven D'Aprano <steve@pearwood.info> - 2016-06-13 12:12 +1000
            Re: for / while else doesn't make sense Rustom Mody <rustompmody@gmail.com> - 2016-06-12 20:46 -0700
            Re: for / while else doesn't make sense Michael Selik <michael.selik@gmail.com> - 2016-06-13 23:45 +0000
              Re: for / while else doesn't make sense Steven D'Aprano <steve@pearwood.info> - 2016-06-14 12:43 +1000
                Re: for / while else doesn't make sense Michael Selik <michael.selik@gmail.com> - 2016-06-14 04:37 +0000
                Re: for / while else doesn't make sense Rustom Mody <rustompmody@gmail.com> - 2016-06-14 08:33 -0700
                  Re: for / while else doesn't make sense Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-14 16:27 -0700
                    Re: for / while else doesn't make sense Rustom Mody <rustompmody@gmail.com> - 2016-06-14 18:29 -0700
                  Re: for / while else doesn't make sense Steven D'Aprano <steve@pearwood.info> - 2016-06-15 13:12 +1000
                    Re: for / while else doesn't make sense Rustom Mody <rustompmody@gmail.com> - 2016-06-14 20:38 -0700
                    Re: for / while else doesn't make sense Rustom Mody <rustompmody@gmail.com> - 2016-06-15 04:19 -0700
                      Re: for / while else doesn't make sense BartC <bc@freeuk.com> - 2016-06-15 13:27 +0100
                        Re: for / while else doesn't make sense Rustom Mody <rustompmody@gmail.com> - 2016-06-15 05:44 -0700
                      Re: for / while else doesn't make sense Random832 <random832@fastmail.com> - 2016-06-15 09:51 -0400
                        Re: for / while else doesn't make sense Rustom Mody <rustompmody@gmail.com> - 2016-06-15 07:20 -0700
                          Re: for / while else doesn't make sense Random832 <random832@fastmail.com> - 2016-06-15 11:54 -0400
                            Re: for / while else doesn't make sense Rustom Mody <rustompmody@gmail.com> - 2016-06-15 10:03 -0700
                              Re: for / while else doesn't make sense BartC <bc@freeuk.com> - 2016-06-15 18:27 +0100
                              Re: for / while else doesn't make sense Steven D'Aprano <steve@pearwood.info> - 2016-06-16 11:40 +1000
                          Re: for / while else doesn't make sense Michael Selik <michael.selik@gmail.com> - 2016-06-15 17:18 +0000
                          Re: for / while else doesn't make sense Random832 <random832@fastmail.com> - 2016-06-15 13:41 -0400
                        Re: for / while else doesn't make sense Rustom Mody <rustompmody@gmail.com> - 2016-06-15 07:31 -0700
                          Re: for / while else doesn't make sense Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-15 19:59 -0700
                        Re: for / while else doesn't make sense Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-15 19:54 -0700
                          What is structured programming (was for/while else doesn't make sense) Rustom Mody <rustompmody@gmail.com> - 2016-06-15 22:48 -0700
                            Re: What is structured programming (was for/while else doesn't make sense) Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-15 22:57 -0700
                              Re: What is structured programming (was for/while else doesn't make sense) Rustom Mody <rustompmody@gmail.com> - 2016-06-16 04:12 -0700
                                Re: What is structured programming (was for/while else doesn't make sense) Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-16 18:53 -0700
                                  Re: What is structured programming (was for/while else doesn't make sense) Rustom Mody <rustompmody@gmail.com> - 2016-06-17 09:32 -0700
                                    Re: What is structured programming (was for/while else doesn't make sense) Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-17 16:07 -0700
                      Re: for / while else doesn't make sense Chris Angelico <rosuav@gmail.com> - 2016-06-15 23:56 +1000
                      Re: for / while else doesn't make sense Steven D'Aprano <steve@pearwood.info> - 2016-06-16 11:19 +1000

Page 11 of 15 — ← Prev page 1 … 9 10 [11] 12 13 … 15  Next page →


#109402

FromBartC <bc@freeuk.com>
Date2016-06-03 10:23 +0100
Message-ID<niric2$giq$1@dont-email.me>
In reply to#109392
On 03/06/2016 02:05, Lawrence D’Oliveiro wrote:
> On Friday, June 3, 2016 at 8:52:52 AM UTC+12, BartC wrote:
>> One major objection was that C's 'for' isn't really a for-statement at
>> all (as it is understood in most other languages that haven't just
>> copied C's version), but is closer to a 'while' statement.
>
> Apart from having local loop variables that get initialized just once. Not something you can fake with a “while” statement.

It's not hard. For:

   for (int A=B; C; D) {BODY}

you just write:

   {int A=B;
    while (C) {
      BODY;
      D;
    }
   }

>
> That’s what makes C’s for-statement so versatile.
>

That's if you're into that. I've only ever use local variables with 
function-wide scope.

If your concern is with optimising, other languages can just have a rule 
about the validity of a for-loop index variable when the loop 
terminates. That's impossible in C because, it being so general purpose, 
there is no such thing as a for-loop index:

   a=0; b=1;
   for (c=2; d<e; ++f) {...}

which one is the loop index? So it is necessary to stick actual 
declarations within the loop. Messy.

(Sorry, we're getting away from Python somewhat!)

-- 
Bartc

[toc] | [prev] | [next] | [standalone]


#109398

FromLawrence D’Oliveiro <lawrencedo99@gmail.com>
Date2016-06-02 19:47 -0700
Message-ID<54595ce1-1639-4c39-8cbb-e285f1bcd0c4@googlegroups.com>
In reply to#109384
On Friday, June 3, 2016 at 8:52:52 AM UTC+12, BartC wrote:
> Simple iterative for-loops are more of a DIY effort...

There is one case that Python handles more nicely than C. And that is iterating over a fixed set of values. E.g. in Python

    for rendering in (False, True) :
        ...
    #end for

versus the (slightly) more long-winded C:

    for (bool rendering = false;;)
      {
        ...
        if (rendering)
            break;
        rendering = true;
      } /*for*/

[toc] | [prev] | [next] | [standalone]


#109403

FromBartC <bc@freeuk.com>
Date2016-06-03 10:32 +0100
Message-ID<nirisu$icd$1@dont-email.me>
In reply to#109398
On 03/06/2016 03:47, Lawrence D’Oliveiro wrote:
> On Friday, June 3, 2016 at 8:52:52 AM UTC+12, BartC wrote:
>> Simple iterative for-loops are more of a DIY effort...
>
> There is one case that Python handles more nicely than C. And that is iterating over a fixed set of values. E.g. in Python
>
>     for rendering in (False, True) :
>         ...
>     #end for
>
> versus the (slightly) more long-winded C:
>
>     for (bool rendering = false;;)
>       {
>         ...
>         if (rendering)
>             break;
>         rendering = true;
>       } /*for*/
>

Just one case? Python is miles away from a C 'for'. There's:

- C's for loop, a glorified while loop where you have specify every 
single detail: for (i=a; i<=b; ++i), including writing your nominated 
loop index three times.

- A 'traditional' for loop, which iterates over the integers A to B or 0 
to N-1 without having to spell out everything: for i=a,b

- A 'forall' kind of loop which iterates over a set of values, which is 
what Python has: for i in x:

-- 
Bartc

[toc] | [prev] | [next] | [standalone]


#109431

FromLawrence D’Oliveiro <lawrencedo99@gmail.com>
Date2016-06-03 09:22 -0700
Message-ID<1c46f375-ad3a-4a82-ad11-f72fd604a53a@googlegroups.com>
In reply to#109403
On Friday, June 3, 2016 at 9:33:32 PM UTC+12, BartC wrote:
> On 03/06/2016 03:47, Lawrence D’Oliveiro wrote:
>> On Friday, June 3, 2016 at 8:52:52 AM UTC+12, BartC wrote:
>>> Simple iterative for-loops are more of a DIY effort...
>>
>> There is one case that Python handles more nicely than C.
> 
> Just one case? Python is miles away from a C 'for'.

Yes, just one case. In Python you write a loop with one exit in one way, a loop with two exits in a different way, and a loop with more than two exits in yet another entirely different way. Can you say “cognitive burden”?

The for-statement in C handles most of my looping requirements. I rarely use while-loops, and do-whiles almost not at all--not for looping, anyway
<https://github.com/ldo/dvd_menu_animator/blob/master/spuhelper.c>.

[toc] | [prev] | [next] | [standalone]


#109456

FromSteven D'Aprano <steve@pearwood.info>
Date2016-06-04 12:20 +1000
Message-ID<57523b00$0$22142$c3e8da3$5496439d@news.astraweb.com>
In reply to#109431
On Sat, 4 Jun 2016 02:22 am, Lawrence D’Oliveiro wrote:

> In Python you write a loop with one exit in one way, a loop with two exits
> in a different way, and a loop with more than two exits in yet another
> entirely different way. Can you say “cognitive burden”?

Yes I can, but I don't see the point.

In Python, you write a loop with one exit one way:

for x in seq:
    do_something()


and a loop with two or more exits a *trivially different* way:

for x in seq:
    do_something()
    if condition:
        break
    if another_condition:
        break


You can put as many or as few break statements in the loop as you like,
whether it is zero or one or ten or a thousand, the for-loop is written the
same way, with a slight difference only when going from the "no early exit"
case to "at least one early exit" case. How is this a cognitive burden?

Programming is about composing code from smaller components in this way.
Here is how you add two numbers:

    result = a + b

and three numbers:

    result = a + b + c

and four numbers:

    result = a + b + c + d

This isn't three or more different ways to add numbers, depending on how
many numbers you have to add. It is ONE way to add, composed as many times
as you need it. For-loops are no different: you can exit the loop by
reaching the end and exiting, or you can exit early by using break. The
number of breaks is just composition.




-- 
Steven

[toc] | [prev] | [next] | [standalone]


#109462

FromLawrence D’Oliveiro <lawrencedo99@gmail.com>
Date2016-06-03 20:41 -0700
Message-ID<c37292c6-8166-434e-93f1-612733c05668@googlegroups.com>
In reply to#109456
On Saturday, June 4, 2016 at 2:22:18 PM UTC+12, Steven D'Aprano wrote:
> and a loop with two or more exits a *trivially different* way:
> 
> for x in seq:
>     do_something()
>     if condition:
>         break
>     if another_condition:
>         break

But that loop has 3 exits, written in two different ways. Why the special case?

[toc] | [prev] | [next] | [standalone]


#109472

FromSteven D'Aprano <steve@pearwood.info>
Date2016-06-04 19:27 +1000
Message-ID<57529f12$0$1612$c3e8da3$5496439d@news.astraweb.com>
In reply to#109462
On Sat, 4 Jun 2016 01:41 pm, Lawrence D’Oliveiro wrote:

> On Saturday, June 4, 2016 at 2:22:18 PM UTC+12, Steven D'Aprano wrote:
>> and a loop with two or more exits a *trivially different* way:
>> 
>> for x in seq:
>>     do_something()
>>     if condition:
>>         break
>>     if another_condition:
>>         break
> 
> But that loop has 3 exits, written in two different ways. Why the special
> case?


Is that a serious question? Are you really questioning the need for
for-loops to stop iterating when they reach the end of the sequence or
iterator?

I'll give you the benefit of the doubt and assume you're not trolling.

A for-loop without "the special case" as you put it, would be an infinite
loop that loops forever unless you explicitly checked for an undefined
value:

for x in [1, 2, 3]:
    print(x, end='')

# prints 1 2 3 UNDEFINED UNDEFINED UNDEFINED UNDEFINED ... 


meaning practically every loop would have to be written as:

for x in seq:
   if x is UNDEFINED:
       break
   process(x)


But at least now you don't have the cognitive burden of remembering that
for-loops are intended to loop over a finite number of items, then stop.

Alternatively, we could just have the for-loop raise an exception when it
passes the end of the sequence. For extra programming machismo, have it
dump core.

Thus the programmer would be responsible for (somehow!) determining how many
times it is safe to loop. This wouldn't be too onerous for sequences:

biggest = len(seq) - 1:
if biggest > -1:
    for i, x in enumerate(seq):
        process(x)
        if i == biggest:
            break


but I leave dealing with iterators as an exercise for the masochistic.


-- 
Steven

[toc] | [prev] | [next] | [standalone]


#109491

FromLawrence D’Oliveiro <lawrencedo99@gmail.com>
Date2016-06-04 20:20 -0700
Message-ID<828e33ff-b3d5-449e-97c3-482fe0b46c68@googlegroups.com>
In reply to#109472
On Saturday, June 4, 2016 at 9:27:58 PM UTC+12, Steven D'Aprano wrote:
> Are you really questioning the need for for-loops to stop iterating
> when they reach the end of the sequence or iterator?

I just want to point out how you turn a discussion about the behaviour of loops into one about the behaviour of for-loops specifically.

> I'll give you the benefit of the doubt and assume you're not trolling.

Please, do not make this personal. That’s a sign of running out of rational things to say.

[toc] | [prev] | [next] | [standalone]


#109479

FromBartC <bc@freeuk.com>
Date2016-06-04 13:55 +0100
Message-ID<niuj4n$6p0$1@dont-email.me>
In reply to#109431
On 03/06/2016 17:22, Lawrence D’Oliveiro wrote:
> On Friday, June 3, 2016 at 9:33:32 PM UTC+12, BartC wrote:
>> On 03/06/2016 03:47, Lawrence D’Oliveiro wrote:
>>> On Friday, June 3, 2016 at 8:52:52 AM UTC+12, BartC wrote:
>>>> Simple iterative for-loops are more of a DIY effort...
>>>
>>> There is one case that Python handles more nicely than C.
>>
>> Just one case? Python is miles away from a C 'for'.
>
> Yes, just one case. In Python you write a loop with one exit in one way, a loop with two exits in a different way, and a loop with more than two exits in yet another entirely different way. Can you say “cognitive burden”?

You mean like this:

  while True:
     if a: break

  while True:
     if a: break
     ...
     if b: break

  while True:
     if a: break
     ...
     if b: break
     ...
     if c: break

> The for-statement in C handles most of my looping requirements.

(Yeah, you might find that does 'if' and 'goto' does as well! As well as 
most other control flow statements including multi-level breaks.)

-- 
Bartc

[toc] | [prev] | [next] | [standalone]


#109393

FromLawrence D’Oliveiro <lawrencedo99@gmail.com>
Date2016-06-02 18:08 -0700
Message-ID<4aafb237-4c41-4c0f-98ec-f71841c36bc1@googlegroups.com>
In reply to#109380
On Friday, June 3, 2016 at 8:09:21 AM UTC+12, Rob Gaddi wrote:
> Although your loop is really the _canonical_ use case for
> 
> for loopvar in range(initial_value, limit+1):
>     processing
>     if found_what_im_looking_for:
>         break
> else:
>     do_whatever_it_is_you_do_when_its_not_found

The reason why I don’t like this is that there are two ways out of the Python for-statement, and they are written quite differently. Why the asymmetry? Logically, all ways out of a loop are of equal significance.

[toc] | [prev] | [next] | [standalone]


#109423

FromRob Gaddi <rgaddi@highlandtechnology.invalid>
Date2016-06-03 15:52 +0000
Message-ID<nis93t$v2m$1@dont-email.me>
In reply to#109393
Lawrence D’Oliveiro wrote:

> On Friday, June 3, 2016 at 8:09:21 AM UTC+12, Rob Gaddi wrote:
>> Although your loop is really the _canonical_ use case for
>> 
>> for loopvar in range(initial_value, limit+1):
>>     processing
>>     if found_what_im_looking_for:
>>         break
>> else:
>>     do_whatever_it_is_you_do_when_its_not_found
>
> The reason why I don’t like this is that there are two ways out of the Python for-statement, and they are written quite differently. Why the asymmetry? Logically, all ways out of a loop are of equal significance.

I wouldn't say that at all.  One is early termination due to success. 
The other is that you've run out of things to try, and exit due to
exhaustion of the iterator.  They're two very different cases, the same
as if I had wrapped the loop in a function:

def roundabout():
   for var in iterable:
       if successful(var): return var
   raise ValueError("Nothing works; all is lost")

-- 
Rob Gaddi, Highland Technology -- www.highlandtechnology.com

Email address domain is currently out of order.  See above to fix.

[toc] | [prev] | [next] | [standalone]


#109432

FromLawrence D’Oliveiro <lawrencedo99@gmail.com>
Date2016-06-03 09:24 -0700
Message-ID<48de4319-7c8a-419a-978c-3cff46f3490a@googlegroups.com>
In reply to#109423
On Saturday, June 4, 2016 at 3:52:42 AM UTC+12, Rob Gaddi wrote:
> Lawrence D’Oliveiro wrote:
> 
>> The reason why I don’t like this is that there are two ways out of the
>> Python for-statement, and they are written quite differently. Why the
>> asymmetry? Logically, all ways out of a loop are of equal significance.
> 
> I wouldn't say that at all.  One is early termination due to success. 
> The other is that you've run out of things to try, and exit due to
> exhaustion of the iterator.  They're two very different cases...

Different in what way? A loop exit is a loop exit. It causes termination of the loop.

[toc] | [prev] | [next] | [standalone]


#109461

FromSteven D'Aprano <steve@pearwood.info>
Date2016-06-04 13:00 +1000
Message-ID<57524448$0$1615$c3e8da3$5496439d@news.astraweb.com>
In reply to#109432
On Sat, 4 Jun 2016 02:24 am, Lawrence D’Oliveiro wrote:

> On Saturday, June 4, 2016 at 3:52:42 AM UTC+12, Rob Gaddi wrote:
>> Lawrence D’Oliveiro wrote:
>> 
>>> The reason why I don’t like this is that there are two ways out of the
>>> Python for-statement, and they are written quite differently. Why the
>>> asymmetry? Logically, all ways out of a loop are of equal significance.
>> 
>> I wouldn't say that at all.  One is early termination due to success.
>> The other is that you've run out of things to try, and exit due to
>> exhaustion of the iterator.  They're two very different cases...
> 
> Different in what way? A loop exit is a loop exit. It causes termination
> of the loop.

You can exit a loop because you have run out of items to process, or you can
exit the loop because a certain condition has been met.

The canonical example is a search, where you need to process differently
depending on whether a match was found or not. In pseudo-code:


for item in items:
    if condition(item):
        # found match, exit loop
        break

if match was found:
    process match
else:
    no match



-- 
Steven

[toc] | [prev] | [next] | [standalone]


#109463

FromLawrence D’Oliveiro <lawrencedo99@gmail.com>
Date2016-06-03 20:43 -0700
Message-ID<12226874-a705-47b1-859c-e9bed59ac6bb@googlegroups.com>
In reply to#109461
On Saturday, June 4, 2016 at 3:00:36 PM UTC+12, Steven D'Aprano wrote:
> You can exit a loop because you have run out of items to process, or you can
> exit the loop because a certain condition has been met.

But why should they be expressed differently?

    item_iter = iter(items)
    while True :
        item = next(item_iter, None)
        if item == None :
            break
        if is_what_i_want(item) :
            break
    #end while

[toc] | [prev] | [next] | [standalone]


#109473

FromNed Batchelder <ned@nedbatchelder.com>
Date2016-06-04 04:37 -0700
Message-ID<6c3b3d2e-bfc0-4c0e-ab81-55ec672f06c9@googlegroups.com>
In reply to#109463
On Friday, June 3, 2016 at 11:43:33 PM UTC-4, Lawrence D’Oliveiro wrote:
> On Saturday, June 4, 2016 at 3:00:36 PM UTC+12, Steven D'Aprano wrote:
> > You can exit a loop because you have run out of items to process, or you can
> > exit the loop because a certain condition has been met.
> 
> But why should they be expressed differently?
> 
>     item_iter = iter(items)
>     while True :
>         item = next(item_iter, None)
>         if item == None :
>             break
>         if is_what_i_want(item) :
>             break
>     #end while

Do you actually write loops like this? If this appeared in a code
review, first we'd have a conversation about what this code was
meant to do, and then I would ask, "Why aren't you using a for loop?"
I suspect most Python programmers would be similarly confused about
why you aren't using one of the central constructs of the language.

What's next? "Why have both if and while? A goto will work for both!"

--Ned.

[toc] | [prev] | [next] | [standalone]


#109492

FromLawrence D’Oliveiro <lawrencedo99@gmail.com>
Date2016-06-04 20:29 -0700
Message-ID<ac1c9579-6113-4647-bbab-c63a863378ef@googlegroups.com>
In reply to#109473
On Saturday, June 4, 2016 at 11:37:18 PM UTC+12, Ned Batchelder wrote:
> On Friday, June 3, 2016 at 11:43:33 PM UTC-4, Lawrence D’Oliveiro wrote:
> > On Saturday, June 4, 2016 at 3:00:36 PM UTC+12, Steven D'Aprano wrote:
> > > You can exit a loop because you have run out of items to process, or you can
> > > exit the loop because a certain condition has been met.
> > 
> > But why should they be expressed differently?
> > 
> >     item_iter = iter(items)
> >     while True :
> >         item = next(item_iter, None)
> >         if item == None :
> >             break
> >         if is_what_i_want(item) :
> >             break
> >     #end while
> 
> Do you actually write loops like this?

Is that a non-trolling question? Yes. All the time.

> If this appeared in a code review, first we'd have a conversation about
> what this code was meant to do ...

I would hope not.

> ...and then I would ask, "Why aren't you using a for loop?"

... and then I would ask, “Didn’t you read my previous postings where I pointed out the issues with them?”

Here <https://en.wikibooks.org/wiki/Python_Programming/Databases> is another example: see the section “Looping on Field Breaks”. A while-True scales gracefully to complex situations like that. I much prefer universal, adaptable constructs, rather than having to remember different solutions for special cases.

> I suspect most Python programmers would be similarly confused about
> why you aren't using one of the central constructs of the language.

When a language has good and bad parts, it behooves the wise programmer to concentrate on the good parts and try to ignore the bad.

Python’s for-loops have their uses—I *did* point this out too, did you not notice?—but they are best confined to the situations that they are good at.

> What's next? "Why have both if and while? A goto will work for both!"

Passive-aggression aside, funny you should mention that. I use a goto-free structured-programming style in my C code, as exemplified here <https://github.com/ldo/dvd_menu_animator/blob/master/spuhelper.c>. I find it reduces problems with forgetting to free memory, or freeing it twice.

[toc] | [prev] | [next] | [standalone]


#109495

FromSteven D'Aprano <steve@pearwood.info>
Date2016-06-05 16:35 +1000
Message-ID<5753c83d$0$1616$c3e8da3$5496439d@news.astraweb.com>
In reply to#109492
On Sun, 5 Jun 2016 01:29 pm, Lawrence D’Oliveiro wrote:

> On Saturday, June 4, 2016 at 11:37:18 PM UTC+12, Ned Batchelder wrote:
>> On Friday, June 3, 2016 at 11:43:33 PM UTC-4, Lawrence D’Oliveiro wrote:
>> > On Saturday, June 4, 2016 at 3:00:36 PM UTC+12, Steven D'Aprano wrote:
>> > > You can exit a loop because you have run out of items to process, or
>> > > you can exit the loop because a certain condition has been met.
>> > 
>> > But why should they be expressed differently?
>> > 
>> >     item_iter = iter(items)
>> >     while True :
>> >         item = next(item_iter, None)
>> >         if item == None :
>> >             break
>> >         if is_what_i_want(item) :
>> >             break
>> >     #end while
>> 
>> Do you actually write loops like this?
> 
> Is that a non-trolling question? Yes. All the time.

Really? Well, you'd fail my code review, because that code is broken. If
items contains None, your loop will silently end early. That's a bug.


>> If this appeared in a code review, first we'd have a conversation about
>> what this code was meant to do ...
> 
> I would hope not.

Clearly. Nevertheless, its a conversation that needs to be had.


>> ...and then I would ask, "Why aren't you using a for loop?"
> 
> ... and then I would ask, “Didn’t you read my previous postings where I
> pointed out the issues with them?”

I don't think that very many people would agree with you or consider them
problems at all. They're more like features than problems. Your objections
to for-loops feel kind of like "I don't like bread knives because they make
it too easy to slice bread".

Okay, you don't like for-loops, because they make looping a fixed number of
times with an optional early exit too much of a "cognitive burden" for you.
You have my sympathy, but nobody else I've come across in nearly two
decades of Python programming finds them a cognitive burden.


> Here <https://en.wikibooks.org/wiki/Python_Programming/Databases> is
> another example: see the section “Looping on Field Breaks”. 

That section was written by you and is not independent confirmation that
others agree with your issues with for-loops.


> A while-True scales gracefully to complex situations like that.

Graceful like a hippopotamus.

I don't know that the situation is complex, your description is pretty clear
and to the point:

    Consider the following scenario: your sales company database has
    a table of employees, and also a table of sales made by each
    employee. You want to loop over these sale entries, and produce
    some per-employee statistics.

but the while loop you have certainly is complex. If I understand your
intent correctly, then I think this is both more elegant and likely faster
than the while loop you use:


# Beware of bugs in the following code: 
# I have only proven it is correct, I haven't tested it.
rows = db_iter(
    db = db,
    cmd =
        "select employees.name, sales.amount, sales.date from"
        " employees left join sales on employees.id = sales.employee_id"
        " order by employees.name, sales.date"
    )
default = {'total sales': 0.0,
           'number of sales': 0,
           'earliest date': None,
           'latest date': None}
prev_employee_name = None
stats = {}
for (employee_name, amount, date) in rows:
    if (employee_name != prev_employee_name 
            and prev_employee_name is not None):
        # Print the previous employee's stats
        report(prev_employee_name, stats)
        # and prepare for the next employee.
        previous_employee_name = employee_name
        stats = default.copy()
    stats['total sales'] += amount
    stats['number of sales'] += 1
    if stats['earliest date'] is None:
        stats['earliest date'] = date
    stats['latest date'] = date

if prev_employee_name is not None:
    report(prev_employee_name, stats)


No breaks needed at all, which makes it much more understandable: you know
instantly from looking at the code that it processes every record exactly
once, then exits.

But it is a *tiny* bit ugly, due to the need to print the last employee's
statistics after the loop is completed. We can fix that in two ways:

(1) Give up the requirement to print each employee's stats as they are
completed, and print them all at the end; or

(2) Put a sentinel at the end of rows.


The first may not be suitable for extremely large data sets, but it is
especially elegant:


rows = db_iter( ... # as above )
default = {'total sales': 0.0, 
           'number of sales': 0,
           'earliest date': None,
           'latest date': None}
stats = {}
for (employee_name, amount, date) in rows:
    record = stats.setdefault(employee_name, default.copy())
    stats['total sales'] += amount
    stats['number of sales'] += 1
    if stats['earliest date'] is None:
        stats['earliest date'] = date
    stats['latest date'] = date
for employee_name in stats:
    report(employee_name, stats[employee_name])


As you now have all the statistics available, you can look for
under-performing or over-performing sales people, run comparisons between
staff, etc.


Solution (2) using a sentinel gets rid of the need to print anything outside
of the loop by simply ensuring that the very last record is a meaningless
sentinel that can be ignored:

from itertools import chain
rows = db_iter( ... # as above )
default = {'total sales': 0.0, 
           'number of sales': 0,
           'earliest date': None,
           'latest date': None}
prev_employee_name = None
stats = {}
for (employee_name, amount, date) in chain(rows, ('', 0, None)):
    if (employee_name != prev_employee_name 
            and prev_employee_name is not None):
        # Print the previous employee's stats
        report(prev_employee_name, stats)
        # and prepare for the next employee.
        previous_employee_name = employee_name
        stats = default.copy()
    stats['total sales'] += amount
    stats['number of sales'] += 1
    if stats['earliest date'] is None:
        stats['earliest date'] = date
    stats['latest date'] = date


Again, there are no breaks needed, so you know that every record is
processed exactly once, and all but the last (the sentinel) is printed.


-- 
Steven

[toc] | [prev] | [next] | [standalone]


#109509

FromNed Batchelder <ned@nedbatchelder.com>
Date2016-06-05 04:29 -0700
Message-ID<7eb86c69-e0c5-4a4e-b35e-d8404bbebf9f@googlegroups.com>
In reply to#109492
On Saturday, June 4, 2016 at 11:29:30 PM UTC-4, Lawrence D’Oliveiro wrote:
> On Saturday, June 4, 2016 at 11:37:18 PM UTC+12, Ned Batchelder wrote:
> > On Friday, June 3, 2016 at 11:43:33 PM UTC-4, Lawrence D’Oliveiro wrote:
> > > On Saturday, June 4, 2016 at 3:00:36 PM UTC+12, Steven D'Aprano wrote:
> > > > You can exit a loop because you have run out of items to process, or you can
> > > > exit the loop because a certain condition has been met.
> > > 
> > > But why should they be expressed differently?
> > > 
> > >     item_iter = iter(items)
> > >     while True :
> > >         item = next(item_iter, None)
> > >         if item == None :
> > >             break
> > >         if is_what_i_want(item) :
> > >             break
> > >     #end while
> > 
> > Do you actually write loops like this?
> 
> Is that a non-trolling question? Yes. All the time.

OK. The best I can say is that you seem to think very differently about
your code than I do.  Re-implementing the logic of iteration just so you
can make the two end conditions look similar seems like a very bad
trade-off to me.  It adds more lines, and more names, and as Steven
points out, more opportunities to introduce errors.

> When a language has good and bad parts, it behooves the wise programmer to concentrate on the good parts and try to ignore the bad.
> 
> Python’s for-loops have their uses—I *did* point this out too, did you not notice?—but they are best confined to the situations that they are good at.

I'm not sure what part of Python you are putting in the "bad" category.
This example didn't involve for/else, so are you saying that break statements
inside for-loops are a bad part?

IIRC, this started as a comparison of Python's for loops and C's.  Do you
also write C for-loops as while statements if they have a break in them,
to make both of those end conditions similar?

I'm not trolling, I'm trying to understand your unusual approach.

--Ned.

[toc] | [prev] | [next] | [standalone]


#109510

FromMarko Rauhamaa <marko@pacujo.net>
Date2016-06-05 14:43 +0300
Message-ID<878tyj97zo.fsf@elektro.pacujo.net>
In reply to#109509
Ned Batchelder <ned@nedbatchelder.com>:

> On Saturday, June 4, 2016 at 11:29:30 PM UTC-4, Lawrence D’Oliveiro wrote:
>> > >     item_iter = iter(items)
>> > >     while True :
>> > >         item = next(item_iter, None)
>> > >         if item == None :
>> > >             break
>> > >         if is_what_i_want(item) :
>> > >             break
>> > >     #end while
>
> OK. The best I can say is that you seem to think very differently
> about your code than I do. Re-implementing the logic of iteration just
> so you can make the two end conditions look similar seems like a very
> bad trade-off to me. It adds more lines, and more names, and as Steven
> points out, more opportunities to introduce errors.

I often experiment with different loop constructs to find the one most
pleasing to the eye. Working directly off iterators is quite rare but a
while-vs-for consideration is frequent. Also, should the stepping part
be in the beginning, middle or end of the loop body?

> I'm not sure what part of Python you are putting in the "bad"
> category. This example didn't involve for/else, so are you saying that
> break statements inside for-loops are a bad part?

It takes time to acclimatize to a new programming language. Initially,
you tend to shun odd-looking constructs like comprehensions. Then, you
might overdo constructs like lambdas and maps. Eventually, you'll find a
style the suits both you and the language.


Marko

[toc] | [prev] | [next] | [standalone]


#109599

FromLawrence D’Oliveiro <lawrencedo99@gmail.com>
Date2016-06-06 17:51 -0700
Message-ID<6fde6944-918a-443e-b44f-0c7a69604a44@googlegroups.com>
In reply to#109510
On Sunday, June 5, 2016 at 11:43:20 PM UTC+12, Marko Rauhamaa wrote:
> I often experiment with different loop constructs to find the one most
> pleasing to the eye. Working directly off iterators is quite rare but a
> while-vs-for consideration is frequent. Also, should the stepping part
> be in the beginning, middle or end of the loop body?

It is nice to have a common, versatile looping form which can be arranged in different ways to suit the problem at hand. That’s why I like the C-style for-statement.

Here’s another example <https://github.com/ldo/ipy_magics/blob/master/rman_magic.py>, for the consideration of those who don’t seem too familiar with looping:

    while True :
        while True :
            line = next(input_line, None)
            if line != None :
                if len(include_stack) == 0 :
                    linenr += 1
                #end if
                break
            #end if
            if len(include_stack) == 0 :
                break
            input_line = include_stack.pop()
        #end while
        if line == None or ... line contains something special ... :
            ...
            if line == None :
                break
            ... process special line ...
            ... replace with None to indicate it’s been processed ...
        #end if
        if line != None :
            ... process regular line ...
        #end if
    #end while

[toc] | [prev] | [next] | [standalone]


Page 11 of 15 — ← Prev page 1 … 9 10 [11] 12 13 … 15  Next page →

Back to top | Article view | comp.lang.python


csiph-web