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


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

What is a function parameter =[] for?

Started byfl <rxjwg98@gmail.com>
First post2015-11-18 13:08 -0800
Last post2015-11-25 03:11 +1100
Articles 20 on this page of 198 — 24 participants

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


Contents

  What is a function parameter =[] for? fl <rxjwg98@gmail.com> - 2015-11-18 13:08 -0800
    Re: What is a function parameter =[] for? John Gordon <gordon@panix.com> - 2015-11-18 22:05 +0000
    Re: What is a function parameter =[] for? Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-18 15:11 -0700
      Re: What is a function parameter =[] for? Grant Edwards <invalid@invalid.invalid> - 2015-11-18 22:33 +0000
      Re: What is a function parameter =[] for? fl <rxjwg98@gmail.com> - 2015-11-18 14:38 -0800
        Re: What is a function parameter =[] for? Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-18 15:47 -0700
        Re: What is a function parameter =[] for? fl <rxjwg98@gmail.com> - 2015-11-18 14:48 -0800
      Re: What is a function parameter =[] for? BartC <bc@freeuk.com> - 2015-11-18 23:14 +0000
        Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-19 10:22 +1100
          Re: What is a function parameter =[] for? BartC <bc@freeuk.com> - 2015-11-19 01:41 +0000
            Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-19 12:59 +1100
              Re: What is a function parameter =[] for? BartC <bc@freeuk.com> - 2015-11-19 11:41 +0000
                Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-19 22:58 +1100
                Re: What is a function parameter =[] for? Steven D'Aprano <steve@pearwood.info> - 2015-11-19 23:45 +1100
                  Re: What is a function parameter =[] for? Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-19 08:42 -0700
                    Re: What is a function parameter =[] for? Steven D'Aprano <steve@pearwood.info> - 2015-11-22 14:58 +1100
                  Re: What is a function parameter =[] for? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-24 13:38 +0100
                    Re: What is a function parameter =[] for? Steven D'Aprano <steve@pearwood.info> - 2015-11-25 04:29 +1100
            Re: What is a function parameter =[] for? Ben Finney <ben+python@benfinney.id.au> - 2015-11-19 13:08 +1100
            Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-19 13:15 +1100
        Re: What is a function parameter =[] for? Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-18 17:02 -0700
        Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-19 11:14 +1100
          Re: What is a function parameter =[] for? fl <rxjwg98@gmail.com> - 2015-11-18 16:34 -0800
            Re: What is a function parameter =[] for? Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-18 17:52 -0700
            Re: What is a function parameter =[] for? MRAB <python@mrabarnett.plus.com> - 2015-11-19 01:02 +0000
            Re: What is a function parameter =[] for? Ben Finney <ben+python@benfinney.id.au> - 2015-11-19 12:26 +1100
            Re: What is a function parameter =[] for? Steven D'Aprano <steve@pearwood.info> - 2015-11-19 22:38 +1100
        Re: What is a function parameter =[] for? Steven D'Aprano <steve@pearwood.info> - 2015-11-19 23:19 +1100
          Re: What is a function parameter =[] for? BartC <bc@freeuk.com> - 2015-11-19 13:19 +0000
            Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-20 00:45 +1100
            Re: What is a function parameter =[] for? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-11-19 09:05 -0500
            Re: What is a function parameter =[] for? Steven D'Aprano <steve@pearwood.info> - 2015-11-20 03:01 +1100
              Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-20 04:30 +1100
              Re: What is a function parameter =[] for? BartC <bc@freeuk.com> - 2015-11-19 17:30 +0000
                Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-20 04:45 +1100
                  Re: What is a function parameter =[] for? BartC <bc@freeuk.com> - 2015-11-19 18:19 +0000
                    Re: What is a function parameter =[] for? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-11-19 18:26 +0000
                      Re: What is a function parameter =[] for? BartC <bc@freeuk.com> - 2015-11-19 18:50 +0000
                        Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-20 06:09 +1100
                          Re: What is a function parameter =[] for? BartC <bc@freeuk.com> - 2015-11-19 19:48 +0000
                            Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-20 06:58 +1100
                        Re: What is a function parameter =[] for? Steven D'Aprano <steve@pearwood.info> - 2015-11-20 11:26 +1100
                          Re: What is a function parameter =[] for? Ned Batchelder <ned@nedbatchelder.com> - 2015-11-19 16:36 -0800
                            Re: What is a function parameter =[] for? Laura Creighton <lac@openend.se> - 2015-11-20 02:00 +0100
                          Re: What is a function parameter =[] for? Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-19 17:59 -0700
                    Re: What is a function parameter =[] for? Marko Rauhamaa <marko@pacujo.net> - 2015-11-19 20:39 +0200
                    Re: What is a function parameter =[] for? Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-19 11:42 -0700
                    Re: What is a function parameter =[] for? Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2015-11-19 18:44 +0000
                    Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-20 06:19 +1100
                      Re: What is a function parameter =[] for? BartC <bc@freeuk.com> - 2015-11-19 21:21 +0000
                        Re: What is a function parameter =[] for? Michael Torrie <torriem@gmail.com> - 2015-11-19 15:55 -0700
                          Re: What is a function parameter =[] for? BartC <bc@freeuk.com> - 2015-11-20 00:11 +0000
                            Re: What is a function parameter =[] for? Ned Batchelder <ned@nedbatchelder.com> - 2015-11-19 16:27 -0800
                              Re: What is a function parameter =[] for? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-24 14:43 +0100
                              Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-25 01:00 +1100
                              Re: What is a function parameter =[] for? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-24 15:24 +0100
                              Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-25 01:34 +1100
                              Re: What is a function parameter =[] for? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-24 16:01 +0100
                              Re: What is a function parameter =[] for? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-24 16:03 +0100
                              Re: What is a function parameter =[] for? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-24 16:12 +0100
                              Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-25 02:17 +1100
                                Re: What is a function parameter =[] for? Steven D'Aprano <steve@pearwood.info> - 2015-11-25 04:54 +1100
                              Re: What is a function parameter =[] for? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-24 16:46 +0100
                              Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-25 02:48 +1100
                              Re: What is a function parameter =[] for? Random832 <random832@fastmail.com> - 2015-11-24 16:28 +0000
                              Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-25 03:38 +1100
                              Re: What is a function parameter =[] for? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-24 17:41 +0100
                              Re: What is a function parameter =[] for? Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-24 09:56 -0700
                              Re: What is a function parameter =[] for? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-24 18:32 +0100
                              Re: What is a function parameter =[] for? Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-24 10:53 -0700
                              Re: What is a function parameter =[] for? Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-24 11:04 -0700
                              Re: What is a function parameter =[] for? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-24 19:45 +0100
                                Re: What is a function parameter =[] for? Ned Batchelder <ned@nedbatchelder.com> - 2015-11-24 10:54 -0800
                              Re: What is a function parameter =[] for? Random832 <random832@fastmail.com> - 2015-11-24 19:00 +0000
                                Re: What is a function parameter =[] for? Steven D'Aprano <steve@pearwood.info> - 2015-11-25 11:34 +1100
                              Re: What is a function parameter =[] for? Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-24 12:15 -0700
                              Re: What is a function parameter =[] for? Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-24 12:15 -0700
                              Re: What is a function parameter =[] for? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-24 21:54 +0100
                                Re: What is a function parameter =[] for? BartC <bc@freeuk.com> - 2015-11-24 21:14 +0000
                                  Re: What is a function parameter =[] for? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-24 22:25 +0100
                                    Re: What is a function parameter =[] for? Steven D'Aprano <steve@pearwood.info> - 2015-11-25 11:36 +1100
                                      Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-25 11:56 +1100
                                      Re: What is a function parameter =[] for? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-25 10:56 +0100
                                        Re: What is a function parameter =[] for? Steven D'Aprano <steve@pearwood.info> - 2015-11-26 04:40 +1100
                                          Re: What is a function parameter =[] for? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-25 19:27 +0100
                                            Re: What is a function parameter =[] for? Steven D'Aprano <steve@pearwood.info> - 2015-11-26 11:10 +1100
                                          Re: What is a function parameter =[] for? Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-25 13:39 -0700
                                          Re: What is a function parameter =[] for? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-25 22:05 +0100
                                          Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-26 09:06 +1100
                                          Re: What is a function parameter =[] for? Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-25 15:38 -0700
                                          Re: What is a function parameter =[] for? Alan Bawden <alan@csail.mit.edu> - 2015-11-25 21:08 -0500
                                            Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-26 13:25 +1100
                                              Re: What is a function parameter =[] for? Alan Bawden <alan@csail.mit.edu> - 2015-11-25 23:27 -0500
                                                Re: What is a function parameter =[] for? Dave Farrance <df@see.replyto.invalid> - 2015-11-26 10:34 +0000
                                                  Re: What is a function parameter =[] for? Marko Rauhamaa <marko@pacujo.net> - 2015-11-26 12:58 +0200
                                                    Re: What is a function parameter =[] for? Dave Farrance <df@see.replyto.invalid> - 2015-11-26 11:12 +0000
                                                      Object identity has no necessary connection to memory location (was: What is a function parameter =[] for?) Ben Finney <ben+python@benfinney.id.au> - 2015-11-26 22:24 +1100
                                                        Re: Object identity has no necessary connection to memory location (was: What is a function parameter =[] for?) Dave Farrance <df@see.replyto.invalid> - 2015-11-26 11:50 +0000
                                                          Re: Object identity has no necessary connection to memory location Ben Finney <ben+python@benfinney.id.au> - 2015-11-27 07:00 +1100
                                                            Re: Object identity has no necessary connection to memory location Steven D'Aprano <steve@pearwood.info> - 2015-11-27 13:17 +1100
                                                          Re: Object identity has no necessary connection to memory location Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-11-26 21:44 +0000
                                                      Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-26 22:24 +1100
                                                      Re: What is a function parameter =[] for? Marko Rauhamaa <marko@pacujo.net> - 2015-11-26 13:27 +0200
                                                      Re: Object identity has no necessary connection to memory location (was: What is a function parameter =[] for?) Chris Angelico <rosuav@gmail.com> - 2015-11-26 22:49 +1100
                                                      Re: Object identity has no necessary connection to memory location Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-26 13:04 +0100
                                                  Re: What is a function parameter =[] for? Steven D'Aprano <steve@pearwood.info> - 2015-11-27 12:34 +1100
                                                    Re: What is a function parameter =[] for? Ben Finney <ben+python@benfinney.id.au> - 2015-11-27 12:40 +1100
                                                      Re: What is a function parameter =[] for? Steven D'Aprano <steve@pearwood.info> - 2015-11-27 13:44 +1100
                                                        Re: What is a function parameter =[] for? MRAB <python@mrabarnett.plus.com> - 2015-11-27 02:56 +0000
                                                          Re: What is a function parameter =[] for? Steven D'Aprano <steve@pearwood.info> - 2015-11-27 23:57 +1100
                                                            Re: What is a function parameter =[] for? Laura Creighton <lac@openend.se> - 2015-11-27 14:24 +0100
                                                            Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-28 00:29 +1100
                                                        Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-27 14:06 +1100
                                                        Re: What is a function parameter =[] for? Ben Finney <ben+python@benfinney.id.au> - 2015-11-27 15:56 +1100
                                                    Re: What is a function parameter =[] for? Random832 <random832@fastmail.com> - 2015-11-26 23:33 -0500
                                            Re: What is a function parameter =[] for? Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-25 19:46 -0700
                                            Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-26 14:02 +1100
                                          Re: What is a function parameter =[] for? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-26 09:15 +0100
                              Re: What is a function parameter =[] for? Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-24 14:33 -0700
                              Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-25 09:09 +1100
                    Re: What is a function parameter =[] for? Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-19 12:25 -0700
                Re: What is a function parameter =[] for? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-11-19 18:20 +0000
                Re: What is a function parameter =[] for? Steven D'Aprano <steve@pearwood.info> - 2015-11-20 12:05 +1100
                  Re: What is a function parameter =[] for? BartC <bc@freeuk.com> - 2015-11-20 11:59 +0000
                    Re: What is a function parameter =[] for? Ned Batchelder <ned@nedbatchelder.com> - 2015-11-20 04:12 -0800
                      Re: What is a function parameter =[] for? BartC <bc@freeuk.com> - 2015-11-20 12:39 +0000
                        Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-21 00:04 +1100
                        Re: What is a function parameter =[] for? Ned Batchelder <ned@nedbatchelder.com> - 2015-11-20 05:30 -0800
                        Re: What is a function parameter =[] for? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-11-20 08:34 -0500
                        Re: What is a function parameter =[] for? Random832 <random832@fastmail.com> - 2015-11-20 14:32 +0000
                        Re: What is a function parameter =[] for? Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-20 09:18 -0700
                        Re: What is a function parameter =[] for? Steven D'Aprano <steve@pearwood.info> - 2015-11-22 23:01 +1100
                        Re: What is a function parameter =[] for? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-11-23 12:30 +1300
                        Re: What is a function parameter =[] for? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-24 15:38 +0100
                      Re: What is a function parameter =[] for? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-24 15:34 +0100
                        Re: What is a function parameter =[] for? Ned Batchelder <ned@nedbatchelder.com> - 2015-11-24 06:50 -0800
                      Re: What is a function parameter =[] for? Terry Reedy <tjreedy@udel.edu> - 2015-11-24 12:46 -0500
                      Re: What is a function parameter =[] for? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-24 19:27 +0100
                    Re: What is a function parameter =[] for? Marko Rauhamaa <marko@pacujo.net> - 2015-11-20 14:28 +0200
                      Re: What is a function parameter =[] for? BartC <bc@freeuk.com> - 2015-11-20 12:53 +0000
                        Re: What is a function parameter =[] for? Random832 <random832@fastmail.com> - 2015-11-20 14:35 +0000
                        Re: What is a function parameter =[] for? Steven D'Aprano <steve@pearwood.info> - 2015-11-22 21:06 +1100
                          Re: What is a function parameter =[] for? Marko Rauhamaa <marko@pacujo.net> - 2015-11-22 14:35 +0200
                      Re: What is a function parameter =[] for? Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-20 09:16 -0700
                        Re: What is a function parameter =[] for? Marko Rauhamaa <marko@pacujo.net> - 2015-11-20 18:31 +0200
                          Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-21 03:37 +1100
                          Re: What is a function parameter =[] for? Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-20 09:39 -0700
                      Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-21 03:24 +1100
                      Re: What is a function parameter =[] for? Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-20 09:29 -0700
                        Re: What is a function parameter =[] for? Marko Rauhamaa <marko@pacujo.net> - 2015-11-20 18:41 +0200
                      Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-21 03:36 +1100
                    Re: What is a function parameter =[] for? Steven D'Aprano <steve@pearwood.info> - 2015-11-22 14:43 +1100
                      Re: What is a function parameter =[] for? BartC <bc@freeuk.com> - 2015-11-22 13:21 +0000
                        Re: What is a function parameter =[] for? BartC <bc@freeuk.com> - 2015-11-22 14:28 +0000
                        Re: What is a function parameter =[] for? Steven D'Aprano <steve@pearwood.info> - 2015-11-23 10:44 +1100
                          Re: What is a function parameter =[] for? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-11-23 00:04 +0000
                            Re: What is a function parameter =[] for? BartC <bc@freeuk.com> - 2015-11-23 00:37 +0000
                              Re: What is a function parameter =[] for? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-11-23 11:32 +0000
                                Re: What is a function parameter =[] for? Ned Batchelder <ned@nedbatchelder.com> - 2015-11-23 04:05 -0800
                              Re: What is a function parameter =[] for? Marko Rauhamaa <marko@pacujo.net> - 2015-11-23 14:23 +0200
                          Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-23 11:20 +1100
                      Re: What is a function parameter =[] for? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-11-23 12:43 +1300
                        Re: What is a function parameter =[] for? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-11-23 18:47 +1100
                          Re: What is a function parameter =[] for? BartC <bc@freeuk.com> - 2015-11-23 10:40 +0000
                            Re: What is a function parameter =[] for? Steven D'Aprano <steve@pearwood.info> - 2015-11-24 00:58 +1100
                              Re: What is a function parameter =[] for? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-24 15:58 +0100
                                Re: What is a function parameter =[] for? Steven D'Aprano <steve@pearwood.info> - 2015-11-25 04:56 +1100
                  Re: What is a function parameter =[] for? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-24 15:18 +0100
                Re: What is a function parameter =[] for? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-24 14:48 +0100
        Re: What is a function parameter =[] for? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-24 12:36 +0100
        Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-24 23:07 +1100
        Re: What is a function parameter =[] for? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-24 13:48 +0100
          Re: What is a function parameter =[] for? Marko Rauhamaa <marko@pacujo.net> - 2015-11-24 14:57 +0200
            Re: What is a function parameter =[] for? Ned Batchelder <ned@nedbatchelder.com> - 2015-11-24 06:18 -0800
              Re: What is a function parameter =[] for? BartC <bc@freeuk.com> - 2015-11-24 14:43 +0000
                Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-25 01:54 +1100
              Re: What is a function parameter =[] for? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-24 16:10 +0100
                Re: What is a function parameter =[] for? Ned Batchelder <ned@nedbatchelder.com> - 2015-11-24 07:27 -0800
                  Re: What is a function parameter =[] for? Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2015-11-24 17:25 +0000
                    Re: What is a function parameter =[] for? Ned Batchelder <ned@nedbatchelder.com> - 2015-11-24 09:35 -0800
                      Re: What is a function parameter =[] for? Marko Rauhamaa <marko@pacujo.net> - 2015-11-24 20:13 +0200
                        Re: What is a function parameter =[] for? Steven D'Aprano <steve@pearwood.info> - 2015-11-25 05:33 +1100
                          Re: What is a function parameter =[] for? Marko Rauhamaa <marko@pacujo.net> - 2015-11-24 21:17 +0200
              Re: What is a function parameter =[] for? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-11-24 11:27 -0500
              Re: What is a function parameter =[] for? Steven D'Aprano <steve@pearwood.info> - 2015-11-25 11:39 +1100
                Re: What is a function parameter =[] for? Laura Creighton <lac@openend.se> - 2015-11-25 01:55 +0100
                A name refers to an object, an object has a value, equality compares values (was: What is a function parameter =[] for?) Ben Finney <ben+python@benfinney.id.au> - 2015-11-25 13:17 +1100
                  Re: A name refers to an object, an object has a value, equality compares values Marko Rauhamaa <marko@pacujo.net> - 2015-11-25 08:44 +0200
                    Re: A name refers to an object, an object has a value, equality compares values Chris Angelico <rosuav@gmail.com> - 2015-11-25 19:27 +1100
                Re: What is a function parameter =[] for? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-25 10:36 +0100
                  Re: What is a function parameter =[] for? Jussi Piitulainen <harvest@should.be.invalid> - 2015-11-25 13:39 +0200
                    Re: What is a function parameter =[] for? Marko Rauhamaa <marko@pacujo.net> - 2015-11-25 14:48 +0200
                      Re: What is a function parameter =[] for? Chris Angelico <rosuav@gmail.com> - 2015-11-26 00:50 +1100
                        Re: What is a function parameter =[] for? Marko Rauhamaa <marko@pacujo.net> - 2015-11-25 16:08 +0200
                      Re: What is a function parameter =[] for? Jussi Piitulainen <harvest@should.be.invalid> - 2015-11-25 17:13 +0200
                        Re: What is a function parameter =[] for? Marko Rauhamaa <marko@pacujo.net> - 2015-11-25 18:44 +0200
                          Re: What is a function parameter =[] for? Jussi Piitulainen <harvest@should.be.invalid> - 2015-11-25 20:30 +0200
            Re: What is a function parameter =[] for? Steven D'Aprano <steve@pearwood.info> - 2015-11-25 03:11 +1100

Page 7 of 10 — ← Prev page 1 … 5 6 [7] 8 9 10  Next page →


#99087

FromIan Kelly <ian.g.kelly@gmail.com>
Date2015-11-19 12:25 -0700
Message-ID<mailman.481.1447961164.16136.python-list@python.org>
In reply to#99078
On Thu, Nov 19, 2015 at 12:19 PM, Chris Angelico <rosuav@gmail.com> wrote:
> But you're
> saying that it "simply substitute[s] the expression", which would mean
> that "func()" is exactly the same as "func(y)". A function default
> argument is therefore able to STEAL STUFF FROM THE CALLER'S SCOPE.
> Sorry for shouting, but if that ain't bizarre, I don't know what is.

It's like pass-by-name, but in reverse.

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


#99079

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2015-11-19 18:20 +0000
Message-ID<mailman.475.1447957292.16136.python-list@python.org>
In reply to#99074
On 19/11/2015 17:30, BartC wrote:
> On 19/11/2015 16:01, Steven D'Aprano wrote:
>> On Fri, 20 Nov 2015 12:19 am, BartC wrote:
>
>> You know, for somebody who claims to design and implement your own
>> languages, you sometimes go to a remarkable effort to claim to be a
>> dummy.
>> You write your own interpreter, but can't understand early versus late
>> binding? I don't think so.
>
> No I don't; so? Maybe my interpreter can do its thing without being
> aware that what it's doing has been called 'late binding' or 'early
> binding' by someone else.
>
> At least its default values work as expected!
>

Python's default values work exactly as I expect as the subject has been 
debated at least twice a year on c.l.py for the 15 or so years that I've 
been using Python.  If your expectations are clearly wrong, that is your 
problem and your problem alone.  A solution to your problem is another 
language that does meet all of your expectations, but as there is never 
a "one size fits all" the only one that I can think of is your own, 
whatever that is called.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


#99117

FromSteven D'Aprano <steve@pearwood.info>
Date2015-11-20 12:05 +1100
Message-ID<564e71f6$0$1619$c3e8da3$5496439d@news.astraweb.com>
In reply to#99074
On Fri, 20 Nov 2015 04:30 am, BartC wrote:

> On 19/11/2015 16:01, Steven D'Aprano wrote:
[...]

> The whole concept of 'mutable' default is alien to me. A default is just 
> a convenient device to avoid having to write:
> 
>    fn(0) or fn("") or fn([])

Says who?

Here's another use for function defaults, as static storage:


# Ackermann's function
def ack(m, n, _memo={}):
    key = m, n
    if key not in _memo:
        if m==0: v = n + 1
        elif n==0: v = ack(m-1, 1)
        else: v = ack(m-1, ack(m, n-1))
        _memo[key] = v
    return _memo[key]


This is a quick and easy way to memoise a function which would otherwise be
horribly slow. And it only works because _memo is bound to a mutable object
once, and once only.

 
> You just write fn() instead. But it shouldn't come at the cost of
> completely different semantics! Because then it can't really be called a
> default value at all.

But it doesn't come with completely different semantics. This is the stock
standard semantics for assignment.

Since we're not passing an argument, let's get rid of the argument
altogether. If we put the assignment inside the body of the function, that
code is executed every time the function is called. "arg" gets a brand new,
empty list each time:

def test():
    arg = []
    arg.append(1)
    return len(arg)


If we put the assignment *outside* of the body of the function, that code is
executed once only, and the same list is used over and over again:

arg = []
def test():
    arg.append(1)
    return len(arg)



This is *exactly* the same semantics as for parameter defaults (except that
they aren't stored as globals, but as hidden fields deep inside the
function object itself). Now, look at the function declaration:


def test(arg=[]):
    arg.append(1)
    return len(arg)


The binding arg=[] is NOT inside the body of the function. Therefore, it is
NOT executed repeatedly, but only once.


>   isn't surprising to
>> somebody coming from a completely different paradigm. I was surprised by
>> it too, the first time I got bitten.
> 
> So you didn't bother reading the LRM either!

LRM? Left Right Manual?

No, I read it. I knew that the list was only created once. But like I said,
I didn't follow the implications of that. If it is only created once, and
you modify the value, the value will be modified.


>> py> def demo_const(x, y=[]):
>> ...     return x + len(y)
> 
>> Exactly as you should expect. Where you run into trouble is when the
>> default value is NOT a constant:
>>
>> py> def demo_variable(x, y=[]):
>> ...     y.append(1)
>> ...     return x + len(y)
> 
> Sorry, what is the default value in each of these? As the first lines of
> the defintions look identical apart from the function names.

The *value* is whatever contents the list holds.

a = []
a.append(1)
a.append(2)
a.append(3)

What's the value of a? Are you shocked and horrified to discover that the
value of a is not the empty list, but the list [1, 2, 3]?



>> py> demo_variable(5)
>> 6
>> py> demo_variable(5)
>> 7
>> py> demo_variable(5)
>> 8
>>
>>
>> If you modify the value, the value will be modified. Why are you
>> surprised by this?
> 
> Which value is being modified? The []?

The object bound to y is being modified. y.append(1) modifies the object
bound to y. That object gets taken from the defaults if you don't supply a
value yourself. That default object starts of life as an empty list, but it
doesn't stay empty if you append to it.



>>>> When you deal with mutable objects, you have to expect them to mutate.
>>>> The whole point of mutability is that their value can change.
>>>
>>> That [] doesn't look like an object that could change.
>>
>> Of course it does.
> 
> You've lost me know.
> 
> Are you saying that:
> 
>    a=[]
> 
> why sometimes not assign an empty list, because that [] could have been
> modified?

No. But [] is syntax for an empty list, and lists can change -- they are
mutable.

a = []
a.append(1)

Are you shocked to learn that a is no longer an empty list? (I know I asked
a similar question before, but this is an important point.)


>> It is a list literal, like int literals, float literals,
>> string literals and the rest.
> 
> Another surprise? Literals by definition can't change:

Says who? The existence of literal syntax is a feature of the programming
language. The mutability of values is a *separate* feature. The two are
unrelated.


> def fn():
> a=[10,20,30]
> a.append(999)
> 
> I would hope that a is set to [10,20,30] at each entry to the function!

Naturally. Each time you call the function, the body of the function
executes and creates a new list. You take that list, and then modify it in
the very next line with a.append(999).

What happens if you only create the list *once*?

a = [10,20,30]
def fn():
    a.append(999)
    print(a)


Are you surprised that a doesn't get reset to [10, 20, 30] each time you
call the function?


>> Assignments are not copies at all.
> 
> if you write A=B then something of B needs to have been copied into A,
> even if it's just the reference that B contains. Otherwise it would be
> difficult to get A to refer to the same object as B.

B doesn't contain the reference to itself. The reference is external to B.
Nothing of B is copied.



-- 
Steven

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


#99138

FromBartC <bc@freeuk.com>
Date2015-11-20 11:59 +0000
Message-ID<n2n1qp$m35$1@dont-email.me>
In reply to#99117
On 20/11/2015 01:05, Steven D'Aprano wrote:
> On Fri, 20 Nov 2015 04:30 am, BartC wrote:
>
>> On 19/11/2015 16:01, Steven D'Aprano wrote:
> [...]
>
>> The whole concept of 'mutable' default is alien to me. A default is just
>> a convenient device to avoid having to write:
>>
>>     fn(0) or fn("") or fn([])
>
> Says who?

People who want to avoid having to write:

      fn(0) or fn("") or fn([])

> Here's another use for function defaults, as static storage:
>
>
> # Ackermann's function
> def ack(m, n, _memo={}):
>      key = m, n
>      if key not in _memo:
>          if m==0: v = n + 1
>          elif n==0: v = ack(m-1, 1)
>          else: v = ack(m-1, ack(m, n-1))
>          _memo[key] = v
>      return _memo[key]
>
>
> This is a quick and easy way to memoise a function which would otherwise be
> horribly slow. And it only works because _memo is bound to a mutable object
> once, and once only.

We're arguing at cross-purposes then since you are obviously interested 
in these esoteric aspects, but all I want to do is avoid remembering a 
long list of defaults. Here's an example from another language, a 
function I'm working on at the minute:

function asklist(caption,&data,n=1, rows=10, width=50, flags="",
                  buttons=(), tablist=(), heading="")=

9 parameters, 7 of them optional. This is designed to be used with 
keyword arguments which is where the default values come into their own, 
as you don't need to remember positional order either.

Very basic stuff and very obvious what it's for. Notice some defaults 
are () (empty lists here), which are the ones that cause bother in Python.

(Here, however, the language doesn't like you doing in-place 
modification of a parameter unless the '&' is used, in which case you 
wouldn't be able to assign a default value such as () as you can only 
pass l-values.)


> def test(arg=[]):
>      arg.append(1)
>      return len(arg)
>
>
> The binding arg=[] is NOT inside the body of the function. Therefore, it is
> NOT executed repeatedly, but only once.

OK, so the "=" is misleading if not a lie.

>> So you didn't bother reading the LRM either!
>
> LRM? Left Right Manual?

Language Reference Manual.

>>>> That [] doesn't look like an object that could change.
>>>
>>> Of course it does.
>>
>> You've lost me know.

> a = []
> a.append(1)
>
> Are you shocked to learn that a is no longer an empty list?

No. But I would be surprised if, after this point, [] is no longer an 
empty list either!

No, forget that; by now, I wouldn't be surprised at all!

(That [] isn't changed is probably thanks to [] being implemented with 
the BUILD_LIST byte-code, which constructs a brand-new empty list each 
time. So the next time [] is used, it will be a different one from the 
one that has just been appended to.

In my language, a construct such as [10,20,30] is evaluated just once at 
start-up. If Python did the same, then I suspect such a literal could 
conceivably be changed if just "=" was used to ______[1] it to 'a'.)

([1] To avoid further argument, insert your own choice of jargon here.)

-- 
Bartc

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


#99139

FromNed Batchelder <ned@nedbatchelder.com>
Date2015-11-20 04:12 -0800
Message-ID<be65d54a-f6dd-4e32-84cf-117e3cad2e37@googlegroups.com>
In reply to#99138
On Friday, November 20, 2015 at 6:59:54 AM UTC-5, BartC wrote:
> On 20/11/2015 01:05, Steven D'Aprano wrote:
> > On Fri, 20 Nov 2015 04:30 am, BartC wrote:
> >
> >> On 19/11/2015 16:01, Steven D'Aprano wrote:
> > [...]
> >
> >> The whole concept of 'mutable' default is alien to me. A default is just
> >> a convenient device to avoid having to write:
> >>
> >>     fn(0) or fn("") or fn([])
> >
> > Says who?
> 
> People who want to avoid having to write:
> 
>       fn(0) or fn("") or fn([])

I think we all understand by now that you are unhappy with what happens
in Python with mutable defaults.  We get it.  You are not alone. Lots of
people are surprised by this.  But it is how Python works.

I'm not sure what your goal is at this point.  Are you:

  1) still unsure what the behavior is, or 
  2) trying to understand why it behaves that way, or
  3) hoping to change Python, or
  4) trying to convince us that your language is better, or
  5) something else?

--Ned.

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


#99141

FromBartC <bc@freeuk.com>
Date2015-11-20 12:39 +0000
Message-ID<n2n46v$uj0$1@dont-email.me>
In reply to#99139
On 20/11/2015 12:12, Ned Batchelder wrote:
> On Friday, November 20, 2015 at 6:59:54 AM UTC-5, BartC wrote:
>> On 20/11/2015 01:05, Steven D'Aprano wrote:
>>> On Fri, 20 Nov 2015 04:30 am, BartC wrote:
>>>
>>>> On 19/11/2015 16:01, Steven D'Aprano wrote:
>>> [...]
>>>
>>>> The whole concept of 'mutable' default is alien to me. A default is just
>>>> a convenient device to avoid having to write:
>>>>
>>>>      fn(0) or fn("") or fn([])
>>>
>>> Says who?
>>
>> People who want to avoid having to write:
>>
>>        fn(0) or fn("") or fn([])
>
> I think we all understand by now that you are unhappy with what happens
> in Python with mutable defaults.  We get it.  You are not alone. Lots of
> people are surprised by this.  But it is how Python works.
>
> I'm not sure what your goal is at this point.  Are you:
>
>    1) still unsure what the behavior is, or
>    2) trying to understand why it behaves that way, or
>    3) hoping to change Python, or
>    4) trying to convince us that your language is better, or
>    5) something else?

Mostly 5. (With a bit of 4. However that language is not something I'm 
selling or pushing. It's just something different used as a contrast.).

What's bothering me is:

* The large amount of mumbo-jumbo used to describe what's going on

* The insistence (I think largely from Steven) that the way this feature 
works is good rather than bad

* The refusal to acknowledge that the def fn(a=[]) syntax is misleading. 
(What value will a have when you call fn()? The true answer is that you 
can't tell.)

* The persistent nonsense that somehow [] is mutable (what happens is 
that [] is assigned to a variable, and /that/ is mutable) (And I will 
probably get some flak now because 'assign' and 'variable' are 
meaningless in Python!)

* And above, where I lay out /why/ people want to use the feature, so 
that the function can take care of some details, even that is refuted.

-- 
Bartc

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


#99143

FromChris Angelico <rosuav@gmail.com>
Date2015-11-21 00:04 +1100
Message-ID<mailman.512.1448024652.16136.python-list@python.org>
In reply to#99141
On Fri, Nov 20, 2015 at 11:39 PM, BartC <bc@freeuk.com> wrote:
> * The refusal to acknowledge that the def fn(a=[]) syntax is misleading.
> (What value will a have when you call fn()? The true answer is that you
> can't tell.)

It isn't misleading. The default value for the argument is set when
the function is defined, and it is set to the *object* that results
from evaluating the *expression* given. After that, the *object* is
the one you will always get (barring shenanigans) if the argument is
omitted. If the value of that object changes, it changes!

You keep expecting the *value* to be consistent. But what you actually
get is that the *object* is consistent. It's virtually impossible to
guarantee the former, in the face of mutable objects.

> * The persistent nonsense that somehow [] is mutable (what happens is that
> [] is assigned to a variable, and /that/ is mutable) (And I will probably
> get some flak now because 'assign' and 'variable' are meaningless in
> Python!)

What happens is that [] evaluates to an object, and *that object* is
mutable. Python does not store the syntactic element "[]" (empty
list-display), but instead stores (a reference to) the object. It's
exactly the same as:

def fn(a=list()):
    ...

def generate_list():
    return []
def fn(a=generate_list()):
    ...

initial_list = []
def fn(a=initial_list):
    ...

import sys
def fn(a=[x*3+424 for x in range(not sys)]):
    """how ridiculous would you like to go?"""

Every one of these constructs exactly one new list, *when it is
evaluated*, which is at function definition time.

ChrisA

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


#99147

FromNed Batchelder <ned@nedbatchelder.com>
Date2015-11-20 05:30 -0800
Message-ID<67bccb9f-6b2f-4ffb-a0e5-71c32587eeb7@googlegroups.com>
In reply to#99141
On Friday, November 20, 2015 at 7:40:37 AM UTC-5, BartC wrote:
> On 20/11/2015 12:12, Ned Batchelder wrote:
> > On Friday, November 20, 2015 at 6:59:54 AM UTC-5, BartC wrote:
> >> On 20/11/2015 01:05, Steven D'Aprano wrote:
> >>> On Fri, 20 Nov 2015 04:30 am, BartC wrote:
> >>>
> >>>> On 19/11/2015 16:01, Steven D'Aprano wrote:
> >>> [...]
> >>>
> >>>> The whole concept of 'mutable' default is alien to me. A default is just
> >>>> a convenient device to avoid having to write:
> >>>>
> >>>>      fn(0) or fn("") or fn([])
> >>>
> >>> Says who?
> >>
> >> People who want to avoid having to write:
> >>
> >>        fn(0) or fn("") or fn([])
> >
> > I think we all understand by now that you are unhappy with what happens
> > in Python with mutable defaults.  We get it.  You are not alone. Lots of
> > people are surprised by this.  But it is how Python works.
> >
> > I'm not sure what your goal is at this point.  Are you:
> >
> >    1) still unsure what the behavior is, or
> >    2) trying to understand why it behaves that way, or
> >    3) hoping to change Python, or
> >    4) trying to convince us that your language is better, or
> >    5) something else?
> 
> Mostly 5. (With a bit of 4. However that language is not something I'm 
> selling or pushing. It's just something different used as a contrast.).
> 
> What's bothering me is:

Let me try to answer some of these.

> 
> * The large amount of mumbo-jumbo used to describe what's going on

We try not to use mumbo-jumbo, we use terms that can be confusing
sometimes.  This page was recommended early on in this thread:
http://nedbatchelder.com/text/names1.html  It is my best attempt to
lay out many of the issues here.  I hope you have had a chance to
read/watch it.

> * The insistence (I think largely from Steven) that the way this feature 
> works is good rather than bad

I think the fairest summary is that the way this works is better than
the alternatives, when you take into account the desire to keep the
semantics of the language simple.

> * The refusal to acknowledge that the def fn(a=[]) syntax is misleading. 
> (What value will a have when you call fn()? The true answer is that you 
> can't tell.)

I completely agree with you that the syntax surprises people.  Anyone who
claims that it isn't surprising is ignoring the abundant empirical evidence
that people new to Python (and even some who have been using it for a long
time) are surprised by this.

But it is not true that "you can't tell" what value a will have.  You have
been surprised by it, but I am confident that if we could sit together, I
could explain to you what value you would get, and it would be clear to you.
You might not like the answer, and it might not be what you first imagined,
but it is not unpredictable.

> * The persistent nonsense that somehow [] is mutable (what happens is 
> that [] is assigned to a variable, and /that/ is mutable) (And I will 
> probably get some flak now because 'assign' and 'variable' are 
> meaningless in Python!)

As others have explained, [] is a value, a list.  Lists are mutable.

    a = []           # Create an empty list
    a.append(1)      #   and mutate that list.

If we don't agree on this, then please please please go and look at the 
page I linked above.  This is a central concept in Python, and we aren't
going to be able to get anywhere if we can't agree on this.

> * And above, where I lay out /why/ people want to use the feature, so 
> that the function can take care of some details, even that is refuted.

I understand why you want to use the feature.  It would be nice if it
came out the way you (and many others) want.  But it doesn't.

--Ned.

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


#99148

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2015-11-20 08:34 -0500
Message-ID<mailman.515.1448026486.16136.python-list@python.org>
In reply to#99141
On Fri, 20 Nov 2015 12:39:58 +0000, BartC <bc@freeuk.com> declaimed the
following:

>* The persistent nonsense that somehow [] is mutable (what happens is 
>that [] is assigned to a variable, and /that/ is mutable) (And I will 
>probably get some flak now because 'assign' and 'variable' are 
>meaningless in Python!)
>
	No... [] is a literal to the compiler which results in the compiler
generating a list OBJECT /at the point where the [] was encountered/. That
object is bound to some name. The name is not mutable, only the contents of
the generated object are mutable.

	You can substitute		list()	where ever you use	[] with no
effective change in the semantics. (I wouldn't be surprised if the parser
was doing that behind the scenes anyway).
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

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


#99153

FromRandom832 <random832@fastmail.com>
Date2015-11-20 14:32 +0000
Message-ID<mailman.519.1448030047.16136.python-list@python.org>
In reply to#99141
On 2015-11-20, Dennis Lee Bieber <wlfraed@ix.netcom.com> wrote:
> 	You can substitute		list()	where ever you use	[] with no
> effective change in the semantics. (I wouldn't be surprised if the parser
> was doing that behind the scenes anyway).

No, because list() does a name lookup on "list" (which is the primary issue
behind every request for frozendict/frozenset literals)

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


#99162

FromIan Kelly <ian.g.kelly@gmail.com>
Date2015-11-20 09:18 -0700
Message-ID<mailman.5.1448036373.2291.python-list@python.org>
In reply to#99141
On Fri, Nov 20, 2015 at 5:39 AM, BartC <bc@freeuk.com> wrote:
> * The persistent nonsense that somehow [] is mutable (what happens is that
> [] is assigned to a variable, and /that/ is mutable) (And I will probably
> get some flak now because 'assign' and 'variable' are meaningless in
> Python!)

I think the problem here is that you're talking as if [] is a unique
value, which it isn't. [] is a list display that *constructs* a list,
not a list itself.

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


#99235

FromSteven D'Aprano <steve@pearwood.info>
Date2015-11-22 23:01 +1100
Message-ID<5651aeb9$0$1601$c3e8da3$5496439d@news.astraweb.com>
In reply to#99141
On Fri, 20 Nov 2015 11:39 pm, BartC wrote:

> What's bothering me is:
> 
> * The large amount of mumbo-jumbo used to describe what's going on

Just because you don't know the terminology doesn't make it mumbo-jumbo. 

That's a particularly unfair and unjustified response to make when multiple
people have spent a lot of their own time, gratis, to explain what is going
on. If you are willing, you can learn a lot here, one of the few places
left where education is still free.


> * The insistence (I think largely from Steven) that the way this feature
> works is good rather than bad

It is good. It's just not good for *everything*.


> * The refusal to acknowledge that the def fn(a=[]) syntax is misleading.
> (What value will a have when you call fn()? The true answer is that you
> can't tell.)

I'm not really sure that anyone has disputed that specific point.

I'd say that the value of the default `a` could change, which is no
different from most other uses of mutable values. This is why some people
insist that mutable values are a mistake, and programming should only
involve immutable, fixed, values.


> * The persistent nonsense that somehow [] is mutable (what happens is
> that [] is assigned to a variable, and /that/ is mutable)

No, objects are mutable, or immutable, as the case may be



-- 
Steven

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


#99246

FromGregory Ewing <greg.ewing@canterbury.ac.nz>
Date2015-11-23 12:30 +1300
Message-ID<dbf1fsFo8teU1@mid.individual.net>
In reply to#99141
BartC wrote:
> What's bothering me is:
> 
> ...
> 
> * The insistence (I think largely from Steven) that the way this feature 
> works is good rather than bad

Here's one reason to prefer the way it currently works:

It's rare to want a mutable default value. The vast
majority of default values are simple things such as
None, 0 or "". Evaluating the default expression on
every call in those cases would just be useless
overhead. So Python optimises for the most common
case. When you need a mutable default, there is a
straightforward way to get it.

-- 
Greg

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


#99344

FromAntoon Pardon <antoon.pardon@rece.vub.ac.be>
Date2015-11-24 15:38 +0100
Message-ID<mailman.122.1448375911.2291.python-list@python.org>
In reply to#99141
Op 20-11-15 om 14:04 schreef Chris Angelico:
> On Fri, Nov 20, 2015 at 11:39 PM, BartC <bc@freeuk.com> wrote:
>> * The refusal to acknowledge that the def fn(a=[]) syntax is misleading.
>> (What value will a have when you call fn()? The true answer is that you
>> can't tell.)
> 
> It isn't misleading. The default value for the argument is set when
> the function is defined, and it is set to the *object* that results
> from evaluating the *expression* given. After that, the *object* is
> the one you will always get (barring shenanigans) if the argument is
> omitted. If the value of that object changes, it changes!

That you can perfectly explain what happens, doesn't contradict that
it is misleading. On the contrary, the fact that one needs all this
explanation in order to grasp what is happening, confirms that it
is misleading.

And you may be talking about objects here. The tutorial talks about
values.

> You keep expecting the *value* to be consistent. But what you actually
> get is that the *object* is consistent. It's virtually impossible to
> guarantee the former, in the face of mutable objects.

What is wrong with expecting the value to be consistent when the tutorial
talks about values?

-- 
Antoon.

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


#99343

FromAntoon Pardon <antoon.pardon@rece.vub.ac.be>
Date2015-11-24 15:34 +0100
Message-ID<mailman.121.1448375661.2291.python-list@python.org>
In reply to#99139
Op 20-11-15 om 13:12 schreef Ned Batchelder:
> On Friday, November 20, 2015 at 6:59:54 AM UTC-5, BartC wrote:
>> On 20/11/2015 01:05, Steven D'Aprano wrote:
>>> On Fri, 20 Nov 2015 04:30 am, BartC wrote:
>>>
>>>> On 19/11/2015 16:01, Steven D'Aprano wrote:
>>> [...]
>>>
>>>> The whole concept of 'mutable' default is alien to me. A default is just
>>>> a convenient device to avoid having to write:
>>>>
>>>>     fn(0) or fn("") or fn([])
>>>
>>> Says who?
>>
>> People who want to avoid having to write:
>>
>>       fn(0) or fn("") or fn([])
> 
> I think we all understand by now that you are unhappy with what happens
> in Python with mutable defaults.  We get it.  You are not alone. Lots of
> people are surprised by this.  But it is how Python works.

May be you should get this message through to the python tribe, so that
they stop reacting as a stung horse each time someone finds something
bizarre with the language.

> I'm not sure what your goal is at this point.  Are you:
> 
>   1) still unsure what the behavior is, or 
>   2) trying to understand why it behaves that way, or
>   3) hoping to change Python, or
>   4) trying to convince us that your language is better, or
>   5) something else?

Maybe just have us recognize that some aspects of python indeed are bizarre.
That there is nothing wrong with him thinking so. After that he will have
to make up his mind whether this bizarre aspect is to big a hurdle for
using the language or not, because it seems unlikely to change.

-- 
Antoon.

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


#99347

FromNed Batchelder <ned@nedbatchelder.com>
Date2015-11-24 06:50 -0800
Message-ID<894f488e-9707-4184-a53f-670a16399665@googlegroups.com>
In reply to#99343
On Tuesday, November 24, 2015 at 9:34:36 AM UTC-5, Antoon Pardon wrote:
> Op 20-11-15 om 13:12 schreef Ned Batchelder:
> > On Friday, November 20, 2015 at 6:59:54 AM UTC-5, BartC wrote:
> >> On 20/11/2015 01:05, Steven D'Aprano wrote:
> >>> On Fri, 20 Nov 2015 04:30 am, BartC wrote:
> >>>
> >>>> On 19/11/2015 16:01, Steven D'Aprano wrote:
> >>> [...]
> >>>
> >>>> The whole concept of 'mutable' default is alien to me. A default is just
> >>>> a convenient device to avoid having to write:
> >>>>
> >>>>     fn(0) or fn("") or fn([])
> >>>
> >>> Says who?
> >>
> >> People who want to avoid having to write:
> >>
> >>       fn(0) or fn("") or fn([])
> > 
> > I think we all understand by now that you are unhappy with what happens
> > in Python with mutable defaults.  We get it.  You are not alone. Lots of
> > people are surprised by this.  But it is how Python works.
> 
> May be you should get this message through to the python tribe, so that
> they stop reacting as a stung horse each time someone finds something
> bizarre with the language.

I agree with you: Python experts shouldn't be surprised when people are
surprised by this behavior.

> 
> > I'm not sure what your goal is at this point.  Are you:
> > 
> >   1) still unsure what the behavior is, or 
> >   2) trying to understand why it behaves that way, or
> >   3) hoping to change Python, or
> >   4) trying to convince us that your language is better, or
> >   5) something else?
> 
> Maybe just have us recognize that some aspects of python indeed are bizarre.
> That there is nothing wrong with him thinking so. After that he will have
> to make up his mind whether this bizarre aspect is to big a hurdle for
> using the language or not, because it seems unlikely to change.

I also agree with you: there is nothing wrong with people thinking parts of
Python are bizarre.  What we ask is that people then try to understand
how Python works.  If people say, "This surprised me, Python is stupid!"
and then leave it there, the conversation is bound to go poorly.

Every language works differently, and every language has things that will
surprise new learners.

--Ned.

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


#99374

FromTerry Reedy <tjreedy@udel.edu>
Date2015-11-24 12:46 -0500
Message-ID<mailman.20.1448387217.20593.python-list@python.org>
In reply to#99139
On 11/24/2015 9:34 AM, Antoon Pardon wrote:

I agree that the tutorial should talk about default argument objects 
(which have values) instead of conflating 'object' with 'value'.

> Op 20-11-15 om 13:12 schreef Ned Batchelder:

>> I'm not sure what your goal is at this point.  Are you:
>>
>>    1) still unsure what the behavior is, or
>>    2) trying to understand why it behaves that way, or
>>    3) hoping to change Python, or
>>    4) trying to convince us that your language is better, or
>>    5) something else?
>
> Maybe just have us recognize that some aspects of python indeed are bizarre.

The current behavior under discussion is: default argument expressions 
are evaluated once at function creation time to produce default argument 
objects that are bound to the function object.  I do not see this as 
bizarre.

> That there is nothing wrong with him thinking so.

I do recognize that some would prefer that default argument expressions 
be treated differently, that

def f(a=expression): pass

be compiled to operate as the following does now

def f(a=None):
     a = a if a is not None else expression

perhaps with None replaced with a hidden object() instance.

I find the continuing fuss over the choice that was made to be the 
bizarre thing here.

-- 
Terry Jan Reedy

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


#99382

FromAntoon Pardon <antoon.pardon@rece.vub.ac.be>
Date2015-11-24 19:27 +0100
Message-ID<mailman.24.1448389642.20593.python-list@python.org>
In reply to#99139
Op 24-11-15 om 18:46 schreef Terry Reedy:
> On 11/24/2015 9:34 AM, Antoon Pardon wrote:
> 
> I agree that the tutorial should talk about default argument objects (which have values) instead of conflating 'object' with 'value'.
> 
>> Op 20-11-15 om 13:12 schreef Ned Batchelder:
> 
>>> I'm not sure what your goal is at this point.  Are you:
>>>
>>>    1) still unsure what the behavior is, or
>>>    2) trying to understand why it behaves that way, or
>>>    3) hoping to change Python, or
>>>    4) trying to convince us that your language is better, or
>>>    5) something else?
>>
>> Maybe just have us recognize that some aspects of python indeed are bizarre.
> 
> The current behavior under discussion is: default argument expressions are evaluated once at function creation
> time to produce default argument objects that are bound to the function object.  I do not see this as bizarre.

I do. That a default can be mutated so that your default can have different values upon
different calls is IMO bizarre. I understand where it is coming from and I can live with
it, but I still find it bizarre.

>> That there is nothing wrong with him thinking so.
> 
> I do recognize that some would prefer that default argument expressions be treated differently, that
> 
> def f(a=expression): pass
> 
> be compiled to operate as the following does now
> 
> def f(a=None):
>     a = a if a is not None else expression
> 
> perhaps with None replaced with a hidden object() instance.

An other possibility could be compiling as the following

_tmp = expression
def f(a = None):
    a = a if a is not None else _tmp.copy()

> 
> I find the continuing fuss over the choice that was made to be the bizarre thing here.
> 

IMO that comes because the python tribe often enough can't handle differences of
appreciation. So what if BartC finds this behaviour bizarre? Why this need to
correct him of that notion? By absolutly wanting to argue that it is not bizarre
the most likely result was that BartC went on the defensive, while if people
would simply have acknowlegded that he is not the only one that finds that
behaviour bizarre and then focused on explaining what happens, a lot less fuss
would have been generated.

-- 
Antoon Pardon.

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


#99140

FromMarko Rauhamaa <marko@pacujo.net>
Date2015-11-20 14:28 +0200
Message-ID<877flcrh26.fsf@elektro.pacujo.net>
In reply to#99138
BartC <bc@freeuk.com>:

> On 20/11/2015 01:05, Steven D'Aprano wrote:
>> On Fri, 20 Nov 2015 04:30 am, BartC wrote:
>>> The whole concept of 'mutable' default is alien to me. A default is just
>>> a convenient device to avoid having to write:
>>>
>>>     fn(0) or fn("") or fn([])
>>
>> Says who?
>
> People who want to avoid having to write:
>
>      fn(0) or fn("") or fn([])

Undoubtedly a mutable default value can lead to accidents. However, I
already showed C++ default values can also be mutable and lead to
analogous problems, so the question is not related to Python alone.

If there is a risk of a default [] or {} ending up in the wrong hands,
you can always write your function with a sentinel:

   omitted = object()

   def f(collection=omitted):
       if collection is omitted:
           collection = []
       ...

> We're arguing at cross-purposes then since you are obviously
> interested in these esoteric aspects,

The Ackermann function really is an esoteric example, but the other
example that has been discussed here can make practical use of the
default-value semantics:

   [ lambda x: i * x for i in range(4) ]

which is salvaged with a default value:

   [ lambda x, i=i: i * x for i in range(4) ]

or, more hygienically:

   [ (lambda i=i: lambda x: i * x)() for i in range(4) ]


Even more appropriately, you may expressly want a mutable, singleton
object to be the default:

   def initiate_query(query, database=global_database):

> but all I want to do is avoid remembering a long list of defaults.
> Here's an example from another language, a function I'm working on at
> the minute:
>
> function asklist(caption,&data,n=1, rows=10, width=50, flags="",
>                  buttons=(), tablist=(), heading="")=

One could argue that you should always use a sentinel object for default
values. That also allows you to distinguish between omitted values and
default values:

   def asklist(caption, data, n=omitted, rows=omitted, width=omitted,
               flags=omitted, buttons=omitted, tablist=omitted,
               heading=omitted):

but that would be rather pedantic in most circumstances.


Marko

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


#99142

FromBartC <bc@freeuk.com>
Date2015-11-20 12:53 +0000
Message-ID<n2n4ve$1no$1@dont-email.me>
In reply to#99140
On 20/11/2015 12:28, Marko Rauhamaa wrote:
> BartC <bc@freeuk.com>:

>> We're arguing at cross-purposes then since you are obviously
>> interested in these esoteric aspects,
>
> The Ackermann function really is an esoteric example, but the other
> example that has been discussed here can make practical use of the
> default-value semantics:

And you go on to give a couple of slightly less esoteric examples! (I 
don't think I've ever written a lambda function in my life.)

> Even more appropriately, you may expressly want a mutable, singleton
> object to be the default:
>
>     def initiate_query(query, database=global_database):

Finally, a down-to-earth example. Here it probably doesn't matter at 
what point 'global_database' gets bound. You know it will always refer 
to the current state of global_database, and you know that it is a data 
structure external to the function even if it is updated from inside.

That is a bit different from an empty list that later is not empty.

>     def asklist(caption, data, n=omitted, rows=omitted, width=omitted,
>                 flags=omitted, buttons=omitted, tablist=omitted,
>                 heading=omitted):
>
> but that would be rather pedantic in most circumstances.

Yes, that's along the lines of what I used do before I had proper 
default values!

Then I had code inside the function to test a parameter and set it as 
needed. I still do this when the default isn't straightforward (where it 
depends on other parameters for example).

-- 
Bartc

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


Page 7 of 10 — ← Prev page 1 … 5 6 [7] 8 9 10  Next page →

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


csiph-web