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 3 of 10 — ← Prev page 1 2 [3] 4 5 … 10  Next page →


#99090

FromChris Angelico <rosuav@gmail.com>
Date2015-11-20 06:58 +1100
Message-ID<mailman.483.1447963125.16136.python-list@python.org>
In reply to#99089
On Fri, Nov 20, 2015 at 6:48 AM, BartC <bc@freeuk.com> wrote:
> On 19/11/2015 19:09, Chris Angelico wrote:
>>
>> On Fri, Nov 20, 2015 at 5:50 AM, BartC <bc@freeuk.com> wrote:
>>>
>>> But you're not going to tell me what it is I got wrong!
>>>
>>> I said that Python's "=" does a very shallow copy. And I stated that in
>>> A=B,
>>> something of B must be copied into A.
>>>
>>> I (and probably others) would like to know why none of that is correct.
>>> But
>>> I suspect I'm not wrong.
>>
>>
>> There's no copying happening. You evaluate the expression `B`, and get
>> back some kind of object (because all expressions in Python evaluate
>> to objects, unless they raise exceptions or in some way don't finish
>> evaluating). The name A then becomes bound to that object. You're not
>> copying a reference; you're simply referencing the result of an
>> expression.
>
>
> OK, so it's just a coincidence that after A=B, id(A) appears to be an
> identical copy of id(B)? And which also agrees with my assertions that a
> very shallow copy is done, and that some aspect of B is duplicated in A.

When you execute A=B, you start by evaluating the expression B. It's
not a coincidence that re-evaluating a simple name immediately
afterward yields the same object:

>>> id(B)
140330420093056
>>> id(B)
140330420093056
>>> id(B)
140330420093056
>>> id(B)
140330420093056

But that's all you've proven. You've shown that the result of
evaluating B twice was the same object each time. That's no proof of
copying; it's just proof that, barring threading or other reentrancy
problems, expressions consisting solely of simple names are stable.

>> It is an excellent explanation of the exact points you're confused about.
>
>
> As far I'm concerned I'm not confused by these copying aspects. I said 'very
> shallow copy', not 'shallow copy' nor 'deep copy' nor just 'copy'. To me,
> 'very shallow copy' about sums it up.
>
> While Python byte-code for A=B:
>
>     6 LOAD_GLOBAL              0 (b)
>     9 STORE_GLOBAL             1 (a)

Technically that's CPython byte code. Python (the language) specifies
the semantics of assignment, but not the exact byte code used.

> doesn't really disagree with me either as it looks remarkably like any other
> basic copy operation of any machine language or byte-code that has ever been
> invented.

I think you're warping the word "copy" to mean what Python does on
assignment, rather than noting an actual similarity between Python
assignment and any other concept of copying. Remember, Python does not
have pointers, in the sense of machine integers storing addresses.
When you assign one C pointer variable to another, yes, you're copying
that integer value; but Python doesn't work that way, so there is
nothing to copy.

ChrisA

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


#99112

FromSteven D'Aprano <steve@pearwood.info>
Date2015-11-20 11:26 +1100
Message-ID<564e68d0$0$1608$c3e8da3$5496439d@news.astraweb.com>
In reply to#99084
On Fri, 20 Nov 2015 05:50 am, BartC wrote:


> I said that Python's "=" does a very shallow copy. And I stated that in
> A=B, something of B must be copied into A.
> 
> I (and probably others) would like to know why none of that is correct.
> But I suspect I'm not wrong.

Nothing of B is copied.

Here is a terrible ASCII art diagram of an object, floating in memory (most
likely in the heap), an instant before the garbage collector can reach it
and collect it:

               +----------------------+
               |  DEADBEEF0012345...  |
               +----------------------+

(Best viewed in a monospaced font, like Courier.)

The contents of the object are shown as a hex-dump, and will depend on the
actual object and its value, but in general you would expect a field which
acts as some sort of tag or pointer linking the instance to its parent
class, plus other fields specifying the object's value and/or attributes.
The internal details of the object don't matter, but basically objects are
structs or records.

Here is an ASCII art diagram of that same object, now bound to the name "B",
preventing the GC from collecting it:

               +----------------------+
B------------->|  DEADBEEF0012345...  |
               +----------------------+

The name "B" may be on the heap, or in an array. It is possible that the
human-readable string "B" itself no longer appears in memory. I don't care
about the specific implementation, but for the record, in the case of
CPython the name "B" is itself a string object in the heap, linked to from
a specific associative array (hash table) also in the heap. (I think.)

The link between the name B and the object ---> could be anything that
allows the compiler/interpreter to associate one to the other. We call it
a "reference". In CPython, references are pointers. If somebody were to
write Python using FORTRAN 77, they would most likely use a big array to
hold the objects, and use the index into the array as references. Other
implementations may use other things, but for simplicity, let's just stick
with calling it a pointer.

Now let's do the assignment A = B:

               +----------------------+
B------------->|  DEADBEEF0012345...  |
            +->+----------------------+
            |
A-----------+

This adds a new reference (think: pointer) to the object, linked to the
name "A". But **nothing of the object** is copied. The pointers to the
object are not part of the object -- they are external to the object.

If you want to talk about anything being copied, you should talk about
*copying the reference* to B, not copying B.

[Aside: there is some ambiguity here. If I say "a reference to B", I
actually mean a reference to the object referenced to by B. I don't mean a
reference to the *name* B. Python doesn't support that feature: names are
not values in Python.]



-- 
Steven

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


#99113

FromNed Batchelder <ned@nedbatchelder.com>
Date2015-11-19 16:36 -0800
Message-ID<f1dc4b01-77e7-4df4-b416-609adb21b772@googlegroups.com>
In reply to#99112
On Thursday, November 19, 2015 at 7:28:44 PM UTC-5, Steven D'Aprano wrote:
> On Fri, 20 Nov 2015 05:50 am, BartC wrote:
> 
> 
> > I said that Python's "=" does a very shallow copy. And I stated that in
> > A=B, something of B must be copied into A.
> > 
> > I (and probably others) would like to know why none of that is correct.
> > But I suspect I'm not wrong.
> 
> Nothing of B is copied.

I think we are stuck in a simple terminology conflict here.  There is something
of B copied.  The name B refers to a value.  In CPython, that reference is a
pointer.  That pointer (the memory address) is copied from B to A.

Nothing of "B's value", that is, the object B is referring to, is copied. But
there is something about B (the pointer to its value) that is now also something
about A, because A also has that pointer.

--Ned.

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


#99116

FromLaura Creighton <lac@openend.se>
Date2015-11-20 02:00 +0100
Message-ID<mailman.502.1447981213.16136.python-list@python.org>
In reply to#99113
In a message of Thu, 19 Nov 2015 16:36:17 -0800, Ned Batchelder writes:
>On Thursday, November 19, 2015 at 7:28:44 PM UTC-5, Steven D'Aprano wrote:
>> On Fri, 20 Nov 2015 05:50 am, BartC wrote:
>> 
>> 
>> > I said that Python's "=" does a very shallow copy. And I stated that in
>> > A=B, something of B must be copied into A.
>> > 
>> > I (and probably others) would like to know why none of that is correct.
>> > But I suspect I'm not wrong.
>> 
>> Nothing of B is copied.
>
>I think we are stuck in a simple terminology conflict here.  There is something
>of B copied.  The name B refers to a value.  In CPython, that reference is a
>pointer.  That pointer (the memory address) is copied from B to A.
>
>Nothing of "B's value", that is, the object B is referring to, is copied. But
>there is something about B (the pointer to its value) that is now also something
>about A, because A also has that pointer.
>
>--Ned.

In PyPy we do this too.
But we don't copy a memory-address pointer.
We have a moving garbage collector, and no objects are in any way
guaranteed to be at their last memory address.

We copy a thing that, when you ask it nicely, spits out "where the hell
is the object right now,  because I want to modify it."

But this thing is in no way tied to any particular place in any DRAM.
It hits PyPy at an abstraction layer above that of 'we write 1s and 0s
here' so if you want to implement python on a message passing system
implemented by carrier pigeon, we could do this.  It would be slow,
however. :)

Laura

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


#99115

FromIan Kelly <ian.g.kelly@gmail.com>
Date2015-11-19 17:59 -0700
Message-ID<mailman.501.1447981191.16136.python-list@python.org>
In reply to#99112
On Nov 19, 2015 5:31 PM, "Steven D'Aprano" <steve@pearwood.info> wrote:
>
> [Aside: there is some ambiguity here. If I say "a reference to B", I
> actually mean a reference to the object referenced to by B. I don't mean a
> reference to the *name* B. Python doesn't support that feature: names are
> not values in Python.]

Quoting BartC:

"""
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.
"""

If you're trying to draw some distinction between what BartC wrote 17 posts
back and what you wrote here, I'm not seeing it.

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


#99081

FromMarko Rauhamaa <marko@pacujo.net>
Date2015-11-19 20:39 +0200
Message-ID<87mvu9esut.fsf@elektro.pacujo.net>
In reply to#99078
BartC <bc@freeuk.com>:

> Yes. In the languages I create, pretty much everything is mutable,
> provided it can supply an l-value. Constructs such as those for empty
> lists ([] in Python, () in mine) aren't l-values.
>
> But it doesn't apply default values.

Python's default-value semantics is analogous to C++:

========================================================================
#include <iostream>

using namespace std;

static int z;

static void f(int &x = z)
{
    x++;
}

int main()
{
    cout << z << endl;
    f();
    cout << z << endl;
    f();
    cout << z << endl;
    return 0;
}
========================================================================

which prints:

    0
    1
    2


Marko

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


#99082

FromIan Kelly <ian.g.kelly@gmail.com>
Date2015-11-19 11:42 -0700
Message-ID<mailman.477.1447958609.16136.python-list@python.org>
In reply to#99078
On Thu, Nov 19, 2015 at 11:26 AM, Mark Lawrence <breamoreboy@yahoo.co.uk> wrote:
> To summarize, it once again shows that you haven't got the faintest idea
> what you're talking about.  You're now in a very exclusive club with the RUE
> and Nick the Greek, the world's leading webmaster.

Eh. Ranting Rick and Mark Janssen / Zipher / TheDoctor / whatever name
he's using now belong in that club, but Nikos was just incompetent,
not a crackpot.

BartC on the other hand is just complaining about an aspect of Python
that is legitimately controversial.

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


#99083

FromOscar Benjamin <oscar.j.benjamin@gmail.com>
Date2015-11-19 18:44 +0000
Message-ID<mailman.478.1447958718.16136.python-list@python.org>
In reply to#99078
On 19 November 2015 at 18:19, BartC <bc@freeuk.com> wrote:
>>>
>>> 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.
>>
>> Please, PLEASE, go and read/watch Ned's PyCon talk (the one I linked
>> you to earlier). Don't post another word on this subject until you
>> comprehend what he is saying.
>
> I looked through the long article (I don't remember seeing a link to a
> video), and followed it up to about 3/4 of the way through, then it got a
> bit heavy.
>
> But what is it about my remarks above that isn't right?

It's not necessarily incorrect (just focussing on the remark quoted
above) but you'll find it easier to understand the model if you adopt
the same terminology that is usually used. When talking of "copying"
in a Python context something different is implied than what happens
with A=B.

The statement A=B (assuming A and B are names and not expressions)
simply binds the name A to the same object that the name B is bound
to. In the implementation of CPython the names are associated with
pointers and the value of the pointer associated with B is copied to
the pointer associated with A. Another implementation may not use
pointers but there will in some way be a "reference" that is "copied"
over if you like to view it that way.

However in a Python context when someone talks of "copying" they will
mean something different: creating a new object which is distinct
from, but has the same value as, some previously existing object. It
is important in Python to distinguish between operations that
create/mutate objects and operations that rebind names. This
distinction has semantic implications that are not hard to understand
if you think about them carefully and consistent use of terminology
really helps.

--
Oscar

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


#99086

FromChris Angelico <rosuav@gmail.com>
Date2015-11-20 06:19 +1100
Message-ID<mailman.480.1447960748.16136.python-list@python.org>
In reply to#99078
On Fri, Nov 20, 2015 at 5:19 AM, BartC <bc@freeuk.com> wrote:
> Yes. In the languages I create, pretty much everything is mutable, provided
> it can supply an l-value. Constructs such as those for empty lists ([] in
> Python, () in mine) aren't l-values.
>
> But it doesn't apply default values. The language is very different however,
> because the byte-code compiler always has full knowledge of functions that
> are called directly. Then it knows when an argument is omitted, and can
> simply substitute the expression used as the default.

In other words, your language uses late binding by default. That's
fine; it's a design choice that you've made one way and Python's made
the other way. It's on par with design choices like whether adding a
string and an integer implicitly stringifies the int, or raises an
error. I know several good languages that have taken each of those
choices.

But every choice has consequences. Steven gave you a few examples of
the consequences of late-binding default arguments. For example, can
you translate this into (one of) your language(s), and explain the
semantics of the late binding?

# scope 1: can be a module, an inner function, whatever
y = 42
def func(x=y):
    return x
def change_y():
    global y # affect the one in this scope
    y = 28

# scope 2: another module/function/etc
from scope1 import func # gain access, however that's done

change_y()
y = 7
func()


Should this return 7, 28, or 42? Early binding demands 42, which is
nice and simple: you don't need to look anywhere outside the
function's own definition to grok its defaults. The default is stable
(it won't change from one run to another - it'll always be the same
object). Scope-recognizing late binding would use 28; it re-evaluates
the expression 'y' in its original scope. This one makes the most
sense to me, of all late-bind semantics; it also happens to be the
same semantics as you get if you do the classic "if x is None: x=y"
late-bind in Python, modulo the effect of the nested scope. 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.

ChrisA

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


#99097

FromBartC <bc@freeuk.com>
Date2015-11-19 21:21 +0000
Message-ID<n2leck$urt$1@dont-email.me>
In reply to#99086
On 19/11/2015 19:19, Chris Angelico wrote:
> On Fri, Nov 20, 2015 at 5:19 AM, BartC <bc@freeuk.com> wrote:

> But every choice has consequences. Steven gave you a few examples of
> the consequences of late-binding default arguments. For example, can
> you translate this into (one of) your language(s), and explain the
> semantics of the late binding?
>
> # scope 1: can be a module, an inner function, whatever
> y = 42
> def func(x=y):
>      return x
> def change_y():
>      global y # affect the one in this scope
>      y = 28
>
> # scope 2: another module/function/etc
> from scope1 import func # gain access, however that's done
>
> change_y()
> y = 7
> func()
>
>
> Should this return 7, 28, or 42?

I tried in two languages and both returned 28 the first time. Then I 
realised I'd missed out the y=7 line. Both then printed 7.

It doesn't matter so much if split across modules or not; it depends 
mainly on whether the y in 'y=7' is the same one in 'x=y' and 'y=28' and 
this depends on how it's declared or not and how.

(Both are here if you're interested: http://pastebin.com/0WPrYQw6)

Actually I'm just glad I got one of the results in your list!

(Python returns 42; so that means my languages are more dynamic than 
Python? That's hard to believe!)


  you don't need to look anywhere outside the
> function's own definition to grok its defaults. The default is stable
> (it won't change from one run to another - it'll always be the same
> object). Scope-recognizing late binding would use 28; it re-evaluates
> the expression 'y' in its original scope. This one makes the most
> sense to me, of all late-bind semantics; it also happens to be the
> same semantics as you get if you do the classic "if x is None: x=y"
> late-bind in Python, modulo the effect of the nested scope. 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.

Well, it's not quite the same as textual substitution of the default 
value expression, which would use names in the local scope at the call site.

The expression is evaluated using the entities in scope where the 
function is defined, as far as I can determine, although the byte-code 
that evaluates it is at the call site.

This is necessary I think because you want the default value to 
evaluated to the same result independently of the actual call site 
(unless the caller has deliberately manipulated things as in your example).

--

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


#99103

FromMichael Torrie <torriem@gmail.com>
Date2015-11-19 15:55 -0700
Message-ID<mailman.495.1447973754.16136.python-list@python.org>
In reply to#99097
On 11/19/2015 02:21 PM, BartC wrote:
> (Python returns 42; so that means my languages are more dynamic than 
> Python? That's hard to believe!)

It tells me your language does late binding for default arguments, which
does mean the default argument can dynamically change at call time,
which would surprise me if I didn't know about it.  Either form of
binding is acceptable, and I don't think it makes a language more or
less dynamic.  Of course as Chris and Laura have said, a list as a
default parameter throws people off because of the semantics of
mutability, and the fact that Python's variable model does not follow
the traditional memory box model used in compiled languages like C.

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


#99110

FromBartC <bc@freeuk.com>
Date2015-11-20 00:11 +0000
Message-ID<n2lobe$7gs$1@dont-email.me>
In reply to#99103
On 19/11/2015 22:55, Michael Torrie wrote:
> On 11/19/2015 02:21 PM, BartC wrote:
>> (Python returns 42; so that means my languages are more dynamic than
>> Python? That's hard to believe!)
>
> It tells me your language does late binding for default arguments, which
> does mean the default argument can dynamically change at call time,
> which would surprise me if I didn't know about it.  Either form of
> binding is acceptable, and I don't think it makes a language more or
> less dynamic.

You get the expression that is specified, which can give different 
values at different times unless it involves only constants.

It can't be exactly the same as writing an identical expression in place 
of the missing argument, as apparently different scopes come into play 
if names are involved.

However I mainly use them for constant values. And [] is a constant 
value in my opinion.

-- 
Bartc

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


#99111

FromNed Batchelder <ned@nedbatchelder.com>
Date2015-11-19 16:27 -0800
Message-ID<8601c9af-a7d9-4642-ba1c-8edd1e4c3390@googlegroups.com>
In reply to#99110
On Thursday, November 19, 2015 at 7:11:52 PM UTC-5, BartC wrote:
> On 19/11/2015 22:55, Michael Torrie wrote:
> > On 11/19/2015 02:21 PM, BartC wrote:
> >> (Python returns 42; so that means my languages are more dynamic than
> >> Python? That's hard to believe!)
> >
> > It tells me your language does late binding for default arguments, which
> > does mean the default argument can dynamically change at call time,
> > which would surprise me if I didn't know about it.  Either form of
> > binding is acceptable, and I don't think it makes a language more or
> > less dynamic.
> 
> You get the expression that is specified, which can give different 
> values at different times unless it involves only constants.
> 
> It can't be exactly the same as writing an identical expression in place 
> of the missing argument, as apparently different scopes come into play 
> if names are involved.
> 
> However I mainly use them for constant values. And [] is a constant 
> value in my opinion.
> 
> -- 
> Bartc

You are not alone in being surprised by how mutable default values work.
It is a topic that comes up in every "What's Bad About Python" discussion,
and is a common question from new users of the language.

I can understand how you would view [] as a constant value.  It's true that
it is an expression that produces a consistent value each time it is
evaluated.  But that value is a list, and lists are mutable.  The examples
here all use the .append() method on that value, which changes it.

Different languages work differently.  In Python, a default value expression
for a function argument is evaluated only once, when the function is defined.
That value (in this case, the actual list) is stored with the function. The
expression is not stored, the value of the expression is. That value (the
actual list) is supplied as the value of the argument if no other value is
supplied.  If you modify that value in the function, the value is modified,
and used again at the next function call.

Again, we understand why you are surprised by this, many people are. You'll
have to accept it, it's just the way Python works.  There have been many
discussions about alternatives, and they are considered to be either too
complicated, or have other undesirable behavior, or both.

--Ned.

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


#99329

FromAntoon Pardon <antoon.pardon@rece.vub.ac.be>
Date2015-11-24 14:43 +0100
Message-ID<mailman.112.1448372618.2291.python-list@python.org>
In reply to#99111
Op 20-11-15 om 01:27 schreef Ned Batchelder:
> On Thursday, November 19, 2015 at 7:11:52 PM UTC-5, BartC wrote:
>> On 19/11/2015 22:55, Michael Torrie wrote:
>>> On 11/19/2015 02:21 PM, BartC wrote:
>>>> (Python returns 42; so that means my languages are more dynamic than
>>>> Python? That's hard to believe!)
>>>
>>> It tells me your language does late binding for default arguments, which
>>> does mean the default argument can dynamically change at call time,
>>> which would surprise me if I didn't know about it.  Either form of
>>> binding is acceptable, and I don't think it makes a language more or
>>> less dynamic.
>>
>> You get the expression that is specified, which can give different 
>> values at different times unless it involves only constants.
>>
>> It can't be exactly the same as writing an identical expression in place 
>> of the missing argument, as apparently different scopes come into play 
>> if names are involved.
>>
>> However I mainly use them for constant values. And [] is a constant 
>> value in my opinion.
>>
>> -- 
>> Bartc
> 
> You are not alone in being surprised by how mutable default values work.
> It is a topic that comes up in every "What's Bad About Python" discussion,
> and is a common question from new users of the language.
> 
> I can understand how you would view [] as a constant value.  It's true that
> it is an expression that produces a consistent value each time it is
> evaluated.  But that value is a list, and lists are mutable.  The examples
> here all use the .append() method on that value, which changes it.

I think that part of the problem is, that [] is not a constant object. So
that when you see a line like

    ls = []

It behaves more lke

    ls = [].copy()

than what you would expect with the normal python semantics.

-- 
Antoon

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


#99333

FromChris Angelico <rosuav@gmail.com>
Date2015-11-25 01:00 +1100
Message-ID<mailman.116.1448373631.2291.python-list@python.org>
In reply to#99111
On Wed, Nov 25, 2015 at 12:43 AM, Antoon Pardon
<antoon.pardon@rece.vub.ac.be> wrote:
> I think that part of the problem is, that [] is not a constant object. So
> that when you see a line like
>
>     ls = []
>
> It behaves more lke
>
>     ls = [].copy()
>
> than what you would expect with the normal python semantics.

You're still thinking in terms of [] being a literal. It isn't; the
docs describe it as "list display", and it's closer to:

ls = list()

except that it doesn't look up the global name. Every time you call
open(), you expect it to open a fresh file handle, right? (Even if you
use the same file name.) And every time you call object(), you get a
new and unique sentinel object. It's the same with list(), and it's
the same with square brackets as well.

Start thinking of it as a constructor call rather than a literal, and
you'll get past most of the confusion.

ChrisA

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


#99340

FromAntoon Pardon <antoon.pardon@rece.vub.ac.be>
Date2015-11-24 15:24 +0100
Message-ID<mailman.118.1448375117.2291.python-list@python.org>
In reply to#99111
Op 24-11-15 om 15:00 schreef Chris Angelico:
> On Wed, Nov 25, 2015 at 12:43 AM, Antoon Pardon
> <antoon.pardon@rece.vub.ac.be> wrote:
>> I think that part of the problem is, that [] is not a constant object. So
>> that when you see a line like
>>
>>     ls = []
>>
>> It behaves more lke
>>
>>     ls = [].copy()
>>
>> than what you would expect with the normal python semantics.
> 
> You're still thinking in terms of [] being a literal. It isn't; the
> docs describe it as "list display", and it's closer to:
> 
> ls = list()

No I am not. The distinction you are making here is unimportant for
the point I am making. And that is that although

    v = ()
and
    v = []

look very similar. They behave differently.

> except that it doesn't look up the global name. Every time you call
> open(), you expect it to open a fresh file handle, right? (Even if you
> use the same file name.) And every time you call object(), you get a
> new and unique sentinel object. It's the same with list(), and it's
> the same with square brackets as well.
> 
> Start thinking of it as a constructor call rather than a literal, and
> you'll get past most of the confusion.

That doesn't change the fact it does look like a literal and not like
a constructor.

-- 
Antoon.

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


#99342

FromChris Angelico <rosuav@gmail.com>
Date2015-11-25 01:34 +1100
Message-ID<mailman.120.1448375647.2291.python-list@python.org>
In reply to#99111
On Wed, Nov 25, 2015 at 1:24 AM, Antoon Pardon
<antoon.pardon@rece.vub.ac.be> wrote:
>> Start thinking of it as a constructor call rather than a literal, and
>> you'll get past most of the confusion.
>
> That doesn't change the fact it does look like a literal and not like
> a constructor.

Then explain how this is a literal:

squares = [x*x for x in range(int(input("How far? ")))]

Or even a simple example like this:

coords = (randrange(10), randrange(10))

Neither of them is a literal, even though one of them isn't even
constructing a list. Tuples may be constant, but they still don't have
a literal form. (Constant folding can make them function the same way
literals do, though. If a tuple is constructed of nothing but
immutable constants - including an empty tuple - then CPython will
generally create a constant for the whole tuple and use that, rather
than manually constructing one every time. But the same is true of
other expressions involving nothing but constants.)

So if it (in your opinion) looks like a literal but isn't one, whose
fault is it? Yours or the language's? Not a rhetorical question.

ChrisA

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


#99350

FromAntoon Pardon <antoon.pardon@rece.vub.ac.be>
Date2015-11-24 16:01 +0100
Message-ID<mailman.1.1448377299.20593.python-list@python.org>
In reply to#99111
Op 24-11-15 om 15:34 schreef Chris Angelico:
> On Wed, Nov 25, 2015 at 1:24 AM, Antoon Pardon
> <antoon.pardon@rece.vub.ac.be> wrote:
>>> Start thinking of it as a constructor call rather than a literal, and
>>> you'll get past most of the confusion.
>>
>> That doesn't change the fact it does look like a literal and not like
>> a constructor.
> 
> Then explain how this is a literal:
> 
> squares = [x*x for x in range(int(input("How far? ")))]
> 
> Or even a simple example like this:
> 
> coords = (randrange(10), randrange(10))
> 
> Neither of them is a literal, even though one of them isn't even
> constructing a list. Tuples may be constant, but they still don't have
> a literal form. (Constant folding can make them function the same way
> literals do, though. If a tuple is constructed of nothing but
> immutable constants - including an empty tuple - then CPython will
> generally create a constant for the whole tuple and use that, rather
> than manually constructing one every time. But the same is true of
> other expressions involving nothing but constants.)
> 
> So if it (in your opinion) looks like a literal but isn't one, whose
> fault is it? Yours or the language's? Not a rhetorical question.
> 
> ChrisA
> 

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


#99351

FromAntoon Pardon <antoon.pardon@rece.vub.ac.be>
Date2015-11-24 16:03 +0100
Message-ID<mailman.2.1448377433.20593.python-list@python.org>
In reply to#99111
Op 24-11-15 om 15:34 schreef Chris Angelico:
> On Wed, Nov 25, 2015 at 1:24 AM, Antoon Pardon
> <antoon.pardon@rece.vub.ac.be> wrote:
>>> Start thinking of it as a constructor call rather than a literal, and
>>> you'll get past most of the confusion.
>>
>> That doesn't change the fact it does look like a literal and not like
>> a constructor.
> 
> Then explain how this is a literal:
> 
> squares = [x*x for x in range(int(input("How far? ")))]

So are you saying

  () isn't a literal

because

  (x * x for x in range(int(input("How far? ")))) isn't a literal?

-- 
Antoon.

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


#99353

FromAntoon Pardon <antoon.pardon@rece.vub.ac.be>
Date2015-11-24 16:12 +0100
Message-ID<mailman.4.1448377944.20593.python-list@python.org>
In reply to#99111
Op 24-11-15 om 15:34 schreef Chris Angelico:
> On Wed, Nov 25, 2015 at 1:24 AM, Antoon Pardon
> <antoon.pardon@rece.vub.ac.be> wrote:
>>> Start thinking of it as a constructor call rather than a literal, and
>>> you'll get past most of the confusion.
>>
>> That doesn't change the fact it does look like a literal and not like
>> a constructor.
> 
> Then explain how this is a literal:
> 
> squares = [x*x for x in range(int(input("How far? ")))]

Are you arguing that () isn't a literal because the following
is not a literal?

squares = (x*x for x in range(int(input("How far? "))))

-- 
Antoon.

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


Page 3 of 10 — ← Prev page 1 2 [3] 4 5 … 10  Next page →

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


csiph-web