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


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

Can global variable be passed into Python function?

Started bySam <lightaiyee@gmail.com>
First post2014-02-20 22:37 -0800
Last post2014-03-01 15:22 +1100
Articles 17 on this page of 217 — 27 participants

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


Contents

  Can global variable be passed into Python function? Sam <lightaiyee@gmail.com> - 2014-02-20 22:37 -0800
    Re: Can global variable be passed into Python function? dieter <dieter@handshake.de> - 2014-02-21 08:23 +0100
      Re: Can global variable be passed into Python function? Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-02-21 10:55 +0200
        Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-21 12:10 +0200
    Re: Can global variable be passed into Python function? Peter Otten <__peter__@web.de> - 2014-02-21 08:34 +0100
    Re: Can global variable be passed into Python function? Gary Herron <gary.herron@islandtraining.com> - 2014-02-21 00:41 -0800
    Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-21 08:55 +0000
    Re: Can global variable be passed into Python function? Ned Batchelder <ned@nedbatchelder.com> - 2014-02-21 07:13 -0500
      Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-21 14:52 +0200
      Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-22 03:28 +0000
        Re: Can global variable be passed into Python function? Ned Batchelder <ned@nedbatchelder.com> - 2014-02-21 22:45 -0500
          Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-22 06:29 +0000
    Re: Can global variable be passed into Python function? Travis Griggs <travisgriggs@gmail.com> - 2014-02-21 09:59 -0800
    Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-22 05:16 +1100
      Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-21 21:20 +0200
        Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-22 17:36 +1100
          Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-22 07:18 +0000
            Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-22 18:29 +1100
              Re: Can global variable be passed into Python function? wxjmfauth@gmail.com - 2014-02-22 00:02 -0800
                Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-22 19:10 +1100
                  Re: Can global variable be passed into Python function? wxjmfauth@gmail.com - 2014-02-22 00:26 -0800
                  Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-22 08:28 +0000
              Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-22 08:35 +0000
                Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-22 19:45 +1100
                Re: Can global variable be passed into Python function? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-02-24 21:07 +1300
                  Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-24 15:57 +0000
                    Re: Can global variable be passed into Python function? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-02-24 21:12 -0500
                    Re: Can global variable be passed into Python function? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-02-26 23:59 +1300
                      Re: Can global variable be passed into Python function? MRAB <python@mrabarnett.plus.com> - 2014-02-26 18:59 +0000
        Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-22 06:57 +0000
          Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-22 09:28 +0200
            Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-22 08:45 +0000
              Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-22 19:54 +1100
    Python and variables (was: Can global variable be passed into Python function?) Ben Finney <ben+python@benfinney.id.au> - 2014-02-22 11:13 +1100
    Re: Can global variable be passed into Python function? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-02-21 21:47 -0500
    Re: Can global variable be passed into Python function? Ned Batchelder <ned@nedbatchelder.com> - 2014-02-21 22:14 -0500
    Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-22 14:15 +0000
      Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-22 16:44 +0200
      Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-23 01:39 +0000
        Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-23 12:50 +1100
          Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-23 06:20 +0000
            Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-23 18:23 +1100
        Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-23 11:52 +0200
          Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-23 10:30 +0000
          Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-23 21:32 +1100
            Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-23 13:01 +0200
              Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-23 22:12 +1100
                Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-23 17:24 +0200
                  Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-24 02:41 +1100
                    Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-23 23:04 +0200
                      Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-23 21:18 +0000
              Re: Can global variable be passed into Python function? Terry Reedy <tjreedy@udel.edu> - 2014-02-23 12:06 -0500
                Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-23 23:10 +0200
                  Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-24 00:37 +0000
                    Re: Can global variable be passed into Python function? wxjmfauth@gmail.com - 2014-02-24 01:35 -0800
              Re: Can global variable be passed into Python function? j.e.haque@gmail.com - 2014-02-24 10:05 -0800
                Re: [OT] Can global variable be passed into Python function? Michael Torrie <torriem@gmail.com> - 2014-02-24 11:19 -0700
                  Re: [OT] Can global variable be passed into Python function? Grant Edwards <invalid@invalid.invalid> - 2014-02-24 19:42 +0000
                    Re: [OT] Can global variable be passed into Python function? Dave Angel <davea@davea.name> - 2014-03-01 23:02 -0500
                      Re: [OT] Can global variable be passed into Python function? Grant Edwards <invalid@invalid.invalid> - 2014-03-02 16:45 +0000
                        Re: [OT] Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-02 16:55 +0000
                        Re: [OT] Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-03 06:24 +1100
                          Re: [OT] Can global variable be passed into Python function? Grant Edwards <invalid@invalid.invalid> - 2014-03-03 14:18 +0000
                            Re: [OT] Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-04 01:25 +1100
                    Re: [OT] Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-02 15:17 +1100
                    Re: [OT] Can global variable be passed into Python function? Dave Angel <davea@davea.name> - 2014-03-02 08:22 -0500
                    Re: [OT] Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-03 00:57 +1100
                    Re: [OT] Can global variable be passed into Python function? Dave Angel <davea@davea.name> - 2014-03-02 14:17 -0500
                    Re: [OT] Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-03 06:32 +1100
                    Re: [OT] Can global variable be passed into Python function? Dave Angel <davea@davea.name> - 2014-03-02 17:58 -0500
                Re: Can global variable be passed into Python function? random832@fastmail.us - 2014-02-24 13:20 -0500
                Re: [OT] Can global variable be passed into Python function? random832@fastmail.us - 2014-02-24 13:21 -0500
                Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-25 05:22 +1100
                Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-25 05:25 +1100
                Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-24 20:00 +0000
    Re: Can global variable be passed into Python function? Dave Angel <davea@davea.name> - 2014-02-22 10:02 -0500
    Re: Can global variable be passed into Python function? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-02-22 13:03 -0500
      Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-23 00:39 +0000
      Re: Can global variable be passed into Python function? Roy Smith <roy@panix.com> - 2014-02-22 19:57 -0500
    Re: Can global variable be passed into Python function? "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-27 05:24 -0800
      Re: Can global variable be passed into Python function? Ned Batchelder <ned@nedbatchelder.com> - 2014-02-27 12:54 -0500
        Re: Can global variable be passed into Python function? "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-27 15:29 -0800
          Re: Can global variable be passed into Python function? Steven D'Aprano <steve@pearwood.info> - 2014-02-28 02:07 +0000
            Re: Can global variable be passed into Python function? "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-27 18:29 -0800
              Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-28 15:43 +1100
                Re: Can global variable be passed into Python function? "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-27 21:39 -0800
                  Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-28 16:53 +1100
                Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-28 09:43 +0200
                  Re: Can global variable be passed into Python function? Steven D'Aprano <steve@pearwood.info> - 2014-02-28 08:23 +0000
                    Re: Can global variable be passed into Python function? Ben Finney <ben+python@benfinney.id.au> - 2014-02-28 19:46 +1100
                      Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-28 12:02 +0200
                        Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-28 21:55 +1100
                          Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-28 13:30 +0200
                            Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-28 22:51 +1100
                              Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-28 14:25 +0200
                                Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-01 00:22 +0000
                        Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-28 22:08 +1100
                          Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-28 13:38 +0200
                            Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-28 23:22 +1100
                            Re: Can global variable be passed into Python function? Neil Cerutti <neilc@norwich.edu> - 2014-02-28 13:47 +0000
                              Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-28 16:26 +0200
                                Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-01 01:37 +1100
                                  Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-28 17:29 +0200
                                    Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-01 02:46 +1100
                                    Re: Can global variable be passed into Python function? Grant Edwards <invalid@invalid.invalid> - 2014-02-28 16:09 +0000
                                      Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-02 10:00 +0200
                                Re: Can global variable be passed into Python function? Roy Smith <roy@panix.com> - 2014-02-28 09:43 -0500
                                  Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-02 10:00 +0200
                                    Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-02 17:26 +0200
                                      Re: Can global variable be passed into Python function? Roy Smith <roy@panix.com> - 2014-03-02 10:34 -0500
                                        Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-02 17:52 +0200
                                          Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-03 03:23 +1100
                                          Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-02 16:53 +0000
                            Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-28 15:06 +0000
                        Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-28 15:50 +0000
                          Re: Can global variable be passed into Python function? "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-28 10:04 -0800
                            Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-28 20:53 +0200
                              Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-01 05:59 +1100
                                Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-28 21:20 +0200
                                  Re: Can global variable be passed into Python function? "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-28 12:22 -0800
                                    Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-28 23:03 +0200
                                      Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-28 21:23 +0000
                                        Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-01 01:06 +0200
                                          Re: Can global variable be passed into Python function? Ben Finney <ben+python@benfinney.id.au> - 2014-03-01 11:02 +1100
                                            Re: Can global variable be passed into Python function? Roy Smith <roy@panix.com> - 2014-02-28 19:48 -0500
                                          Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-01 13:00 +1100
                                            Re: Can global variable be passed into Python function? Roy Smith <roy@panix.com> - 2014-02-28 22:15 -0500
                                        Re: Can global variable be passed into Python function? Grant Edwards <invalid@invalid.invalid> - 2014-02-28 22:00 +0000
                                          Re: Can global variable be passed into Python function? Ben Finney <ben+python@benfinney.id.au> - 2014-03-02 09:36 +1100
                                            Re: Can global variable be passed into Python function? "Mark H. Harris" <harrismh777@gmail.com> - 2014-03-01 14:50 -0800
                                      Re: Can global variable be passed into Python function? "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-28 15:36 -0800
                                        Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-01 02:32 +0200
                                        Re: Can global variable be passed into Python function? Ned Batchelder <ned@nedbatchelder.com> - 2014-02-28 19:40 -0500
                                          Re: Can global variable be passed into Python function? "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-28 17:08 -0800
                                            Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-01 13:01 +1100
                                              Re: Can global variable be passed into Python function? "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-28 21:30 -0800
                                                Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-01 17:24 +1100
                                                  Re: Can global variable be passed into Python function? "Mark H. Harris" <harrismh777@gmail.com> - 2014-03-01 13:40 -0800
                                                    Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-01 22:01 +0000
                                                      Re: Can global variable be passed into Python function? "Mark H. Harris" <harrismh777@gmail.com> - 2014-03-01 14:07 -0800
                                                        Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-01 23:21 +0000
                                                          Re: Can global variable be passed into Python function? "Mark H. Harris" <harrismh777@gmail.com> - 2014-03-01 16:23 -0800
                                                            Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-02 11:28 +1100
                                                            Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-02 00:36 +0000
                                                            Re: Can global variable be passed into Python function? Ned Deily <nad@acm.org> - 2014-03-01 16:55 -0800
                                                            Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-02 01:15 +0000
                                                    Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-02 09:11 +1100
                                            Re: Can global variable be passed into Python function? Ned Batchelder <ned@nedbatchelder.com> - 2014-02-28 21:15 -0500
                                              Re: Can global variable be passed into Python function? "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-28 20:36 -0800
                                        Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-01 01:07 +0000
                                        Re: Can global variable be passed into Python function? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-03-01 16:10 +1300
                                        Re: Can global variable be passed into Python function? Roy Smith <roy@panix.com> - 2014-02-28 19:02 -0500
                                  Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-28 23:33 +0000
                                  Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-01 12:50 +1100
                              Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-28 23:04 +0000
                                Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-01 02:03 +0200
                                  Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-01 00:44 +0000
                                    Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-01 03:06 +0200
                                      Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-01 01:59 +0000
                                        Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-01 13:03 +1100
                                          Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-01 03:29 +0000
                                        Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-01 12:39 +0200
                                  Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-01 01:10 +0000
                                    Re: Can global variable be passed into Python function? "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-28 17:29 -0800
                        Re: Can global variable be passed into Python function? Ben Finney <ben+python@benfinney.id.au> - 2014-03-01 10:17 +1100
                          Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-01 02:11 +0200
                            Re: Can global variable be passed into Python function? Ben Finney <ben+python@benfinney.id.au> - 2014-03-01 11:50 +1100
                              Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-01 03:10 +0200
                                Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-01 01:19 +0000
                                Re: Can global variable be passed into Python function? Ben Finney <ben+python@benfinney.id.au> - 2014-03-01 12:41 +1100
                                  Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-01 12:31 +0200
                                    Re: Can global variable be passed into Python function? Ben Finney <ben+python@benfinney.id.au> - 2014-03-01 21:48 +1100
                                      Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-01 13:28 +0200
                                        Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-01 22:59 +1100
                                          Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-01 17:07 +0000
                                            Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-02 04:27 +1100
                                            Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-01 20:25 +0200
                                              Re: Can global variable be passed into Python function? Ben Finney <ben+python@benfinney.id.au> - 2014-03-02 09:30 +1100
                                              Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-01 23:13 +0000
                                        Re: Can global variable be passed into Python function? Ben Finney <ben+python@benfinney.id.au> - 2014-03-02 00:03 +1100
                                          Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-01 19:23 +0200
                                            Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-02 04:30 +1100
                                            Re: Can global variable be passed into Python function? Ben Finney <ben+python@benfinney.id.au> - 2014-03-02 09:34 +1100
                                              Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-02 10:03 +0200
                                                Re: Can global variable be passed into Python function? Ben Finney <ben+python@benfinney.id.au> - 2014-03-02 21:59 +1100
                                                Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-02 13:00 +0000
                                        Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-01 15:15 +0000
                                        Re: Can global variable be passed into Python function? Michael Torrie <torriem@gmail.com> - 2014-03-01 10:05 -0700
                                          Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-01 19:29 +0200
                                            Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-02 04:36 +1100
                                            Re: Can global variable be passed into Python function? Michael Torrie <torriem@gmail.com> - 2014-03-01 11:06 -0700
                                            Re: Can global variable be passed into Python function? Roy Smith <roy@panix.com> - 2014-03-01 13:30 -0500
                                            Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-02 08:35 +0000
                                              Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-02 11:35 +0200
                                                Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-02 11:40 +0200
                                                Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-02 21:07 +1100
                                                  Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-02 12:37 +0200
                                                Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-02 10:44 +0000
                                                  Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-02 13:33 +0200
                                                    Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-03 01:50 +0000
                                                Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-02 13:04 +0000
                                                Re: Can global variable be passed into Python function? Michael Torrie <torriem@gmail.com> - 2014-03-02 11:48 -0700
                                                  Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-02 23:03 +0200
                                                    Re: Can global variable be passed into Python function? Roy Smith <roy@panix.com> - 2014-03-02 16:16 -0500
                                                    Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-03 08:28 +1100
                                                    Re: Can global variable be passed into Python function? Michael Torrie <torriem@gmail.com> - 2014-03-02 14:44 -0700
                                                      Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-03 00:46 +0200
                                    Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-01 17:18 +0000
                            Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-01 00:58 +0000
                    Re: Can global variable be passed into Python function? Michael Torrie <torriem@gmail.com> - 2014-02-28 07:49 -0700
                  Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-28 20:00 +1100
                  Re: Can global variable be passed into Python function? Grant Edwards <invalid@invalid.invalid> - 2014-02-28 14:20 +0000
          References, and avoiding use of “variable” (was: Can global variable be passed into Python function?) Ben Finney <ben+python@benfinney.id.au> - 2014-02-28 13:46 +1100
          Re: References, and avoiding use of ???variable??? (was: Can global variable be passed into Python function?) Neil Cerutti <neilc@norwich.edu> - 2014-02-28 14:30 +0000
          Re: References, and avoiding use of ???variable??? Ben Finney <ben+python@benfinney.id.au> - 2014-03-01 10:33 +1100
            Re: References, and avoiding use of ???variable??? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-03-01 16:08 +1300
              Re: References, and avoiding use of ???variable??? Ben Finney <ben+python@benfinney.id.au> - 2014-03-01 15:22 +1100

Page 11 of 11 — ← Prev page 1 … 9 10 [11]


#67435

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2014-03-02 13:04 +0000
Message-ID<mailman.7575.1393765506.18130.python-list@python.org>
In reply to#67419
On 02/03/2014 09:35, Marko Rauhamaa wrote:
> Steven D'Aprano <steve+comp.lang.python@pearwood.info>:
>
>> On Sat, 01 Mar 2014 19:29:41 +0200, Marko Rauhamaa wrote:
>>> Michael Torrie <torriem@gmail.com>:
>>>> No, '==' works fine no matter what objects you assign to your state
>>>> variables.
>>>
>>> Well, it doesn't since
>>>
>>>     >>> a = float("nan")
>>>     >>> a is a
>>>     True
>>>     >>> a == a
>>>     False
>>
>> No, that is working correctly, so the comment that equals works fine
>> is correct: returning False is the correct thing to do if one or both
>> of the objects are a NAN. NANs are supposed to compare unequal to
>> everything, including themselves.
>
> Nobody is saying there's a bug in the implementation of "==". I'm just
> saying "==" cannot be taken as a universal superset of "is". Therefore
> a program cannot blindly use "==" to test for identity.
>
> That's why "==" is a bit fishy. It immediately raises the question: what
> does it mean for a == b, especially since the exact implementation of a
> and b are intended to be opaque.
>
> Example:
>
> The os module defines the constants os.SEEK_SET, os.SEEK_CUR and
> os.SEEK_END that can be used as arguments for os.lseek(). Must those
> constants be used, or can a regular integer be used instead? The
> documentation clearly states that integers can be used:
>
>     SEEK_SET or 0 to set the position relative to the beginning of the
>     file; SEEK_CUR or 1 to set it relative to the current position;
>     SEEK_END or 2 to set it relative to the end of the file.
>
> However, on the same reference page, os.posix_fadvise() is defined. We
> read:
>
>     advice is one of POSIX_FADV_NORMAL, POSIX_FADV_SEQUENTIAL,
>     POSIX_FADV_RANDOM, POSIX_FADV_NOREUSE, POSIX_FADV_WILLNEED or
>     POSIX_FADV_DONTNEED
>
> and:
>
>      os.POSIX_FADV_NORMAL
>      os.POSIX_FADV_SEQUENTIAL
>      os.POSIX_FADV_RANDOM
>      os.POSIX_FADV_NOREUSE
>      os.POSIX_FADV_WILLNEED
>      os.POSIX_FADV_DONTNEED
>
>      Flags that can be used in advice in posix_fadvise()
>
> Now, what kinds of object are those constants? We are not supposed to
> know or care. We could peek into the implementation, but it would be a
> grave mistake to trust the implementation choices in the application.
>
> So in my application code I might set:
>
>     favd_flag = os.POSIX_FADV_RANDOM
>
> in some other part of my code I might want to see how "flag" was set.
> Should I use "==" or "is" to test it?
>
> If I take the API documentation on its face value, I *must* use "==" for
> os.SEEK*:
>
>      if seek_flag == os.SEEK_END:
>          ...
>
> and I *must* use "is" for os.POSIX_FAVD_*:
>
>      if fsavd_flag is os.POSIX_FADV_RANDOM:
>          ...
>
> Since, for all I know, os.POSIX_FAVD_RANDOM might return a random value
> for __eq__().
>
>
> Marko
>

Will you please be kind enough to stop writing this drivel.  You've been 
told repeatedly that you don't know what you're talking about, so have 
the decency to just belt up.  Now try testing these words for identity.

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

Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

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


#67458

FromMichael Torrie <torriem@gmail.com>
Date2014-03-02 11:48 -0700
Message-ID<mailman.7588.1393786109.18130.python-list@python.org>
In reply to#67419
On 03/02/2014 03:07 AM, Chris Angelico wrote:
> 
>>>> import os
>>>> type(os.POSIX_FADV_RANDOM)
> <class 'int'>
> 
> So use ==. If it's later changed and you have to instead use 'is', you
> can change your code.

I don't see why == wouldn't continue to work if os.POSIX_FADV_RANDOM
became an object of a different type.

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


#67467

FromMarko Rauhamaa <marko@pacujo.net>
Date2014-03-02 23:03 +0200
Message-ID<87txbg48kd.fsf@elektro.pacujo.net>
In reply to#67458
Michael Torrie <torriem@gmail.com>:

> I don't see why == wouldn't continue to work if os.POSIX_FADV_RANDOM
> became an object of a different type.

It probably would.

If one were begging for trouble, one *could* define:

   class ABC:
       A = 1
       B = 1.0
       C = 1+0j

Now:

   ABC.A == ABC.B
   ABC.B == ABC.C
   ABC.C == ABC.A

but:

   ABC.A is not ABC.B
   ABC.B is not ABC.C
   ABC.C is not ABC.A


Marko

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


#67468

FromRoy Smith <roy@panix.com>
Date2014-03-02 16:16 -0500
Message-ID<roy-E6687F.16161402032014@news.panix.com>
In reply to#67467
In article <87txbg48kd.fsf@elektro.pacujo.net>,
 Marko Rauhamaa <marko@pacujo.net> wrote:

> Michael Torrie <torriem@gmail.com>:
> 
> > I don't see why == wouldn't continue to work if os.POSIX_FADV_RANDOM
> > became an object of a different type.
> 
> It probably would.
> 
> If one were begging for trouble, one *could* define:
> 
>    class ABC:
>        A = 1
>        B = 1.0
>        C = 1+0j
> 
> Now:
> 
>    ABC.A == ABC.B
>    ABC.B == ABC.C
>    ABC.C == ABC.A
> 
> but:
> 
>    ABC.A is not ABC.B
>    ABC.B is not ABC.C
>    ABC.C is not ABC.A
> 
> 
> Marko

On can do all sorts of bizarre things.  If you wish to shoot yourself in 
the foot, Python is happy to provide the gun.

class ABC(object):
    _instance = None
    def __new__(cls):
        if cls._instance is None:
            i = object.__new__(cls)
            i.__class__ = ABC
            cls._instance = i
        return cls._instance

    def __eq__(self, other):
        return False

a = ABC()
b = ABC()

print a is b
print a == b

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


#67469

FromChris Angelico <rosuav@gmail.com>
Date2014-03-03 08:28 +1100
Message-ID<mailman.7595.1393795705.18130.python-list@python.org>
In reply to#67467
On Mon, Mar 3, 2014 at 8:03 AM, Marko Rauhamaa <marko@pacujo.net> wrote:
> If one were begging for trouble, one *could* define:
>
>    class ABC:
>        A = 1
>        B = 1.0
>        C = 1+0j

You're missing the point of flags, though. One does not use floats for
flags. Flags are normally going to be integers (passed directly to an
underlying C API), strings (self-documenting), or arbitrary objects
with no value beyond their identities. In all cases, value equality is
the normal way to recognize them, except in the special case of
bit-flag integers, where you use bitwise operations (and then equality
checks, possibly):

DIRECTORY = 512 # Not sure that one's right, tbh
OWNER_READ = 256
OWNER_WRITE = 128
OWNER_EXEC = 64
GROUP_READ = 32
...
OTHERS_EXEC = 1

mode = 1005
if mode & DIRECTORY:
    # It's a directory!
if mode & OTHERS_READ:
    # You're allowed to read (eg 'ls')
if mode & GROUP_EXEC:
    # You get the idea.

With multi-bit flags you might have to do a bitwise AND followed by an
equality check:

NOT_STICKY = 0
STICKY_PARTIAL = 16
STICKY_MOSTLY = 32
STICKY_ENTIRELY = 48
STICKY_BITS = 48

if style & STICKY_BITS == STICKY_MOSTLY:
    # I've no idea what this means, actually

At no time can you do identity checks. It might happen to work with
the lower bit values and CPython, but when you check the 2048 bit, you
don't get that. Value is all that matters.

ChrisA

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


#67471

FromMichael Torrie <torriem@gmail.com>
Date2014-03-02 14:44 -0700
Message-ID<mailman.7596.1393796658.18130.python-list@python.org>
In reply to#67467
On 03/02/2014 02:03 PM, Marko Rauhamaa wrote:
> Michael Torrie <torriem@gmail.com>:
> 
>> I don't see why == wouldn't continue to work if os.POSIX_FADV_RANDOM
>> became an object of a different type.
> 
> It probably would.
> 
> If one were begging for trouble, one *could* define:
> 
>    class ABC:
>        A = 1
>        B = 1.0
>        C = 1+0j

And one could also set A=1 and B=1 if he was trying to be stupid.  That
would fail the equality test and the identity test (in CPython).  Seems
like this argument is getting a bit on the absurd side.  The normal
idiom is to use equality checks to test state variables' *values*.  I
don't know of any developer that would purposely try to break that when
defining a new module or class.

If Mark H wants to use an idiom that isn't conventional, or isn't widely
used, he is free to do so; I can't see much harm in it.  But certainly
it's not the "normal" way that it's done in Python from what I can see.

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


#67474

FromMarko Rauhamaa <marko@pacujo.net>
Date2014-03-03 00:46 +0200
Message-ID<87lhws43s6.fsf@elektro.pacujo.net>
In reply to#67471
Michael Torrie <torriem@gmail.com>:

> And one could also set A=1 and B=1 if he was trying to be stupid.
> [...]
> If Mark H wants to use an idiom that isn't conventional, or isn't
> widely used, he is free to do so; I can't see much harm in it. But
> certainly it's not the "normal" way that it's done in Python from what
> I can see.

You might be referring to what I have proposed.

Note that the idiom is in use in some standard python modules
(socket.py, ftplib.py, argparse.py, optparse.py). It is used extensively
in sre_compile.py/sre_constants.py:

   ANY = "any"
   [...]
   AT = "at"
   [...]
   CALL = "call"
   [...]
   IN = "in"

           elif op is IN:
           [...]
           elif op is ANY:
           [...]
           elif op is CALL:
           [...]
           elif op is AT:


Marko

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


#67322

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2014-03-01 17:18 +0000
Message-ID<5312165e$0$29985$c3e8da3$5496439d@news.astraweb.com>
In reply to#67304
On Sat, 01 Mar 2014 12:31:39 +0200, Marko Rauhamaa wrote:

> I need *identifiers*. I could simply define:
> 
>    class ABC:
>        A = object()
>        B = object()
>        C = object()
> 
> The program would work perfectly.
> 
> Except, if it's got a bug. I know self.abc contains either A, B or C,
> but which one? Printing out self.abc won't give me any help. I could
> print out ABC.A, ABC.B and ABC.C and see which one matches, but that's
> cumbersome.

All very good so far.

 
> The next variant is to use objects that have names:
> 
>    class Symbol:
>        def __init__(self, name):
>            self.name = name
>        def __str__(self):
>            return self.name
> 
>    class ABC:
>        A = Symbol("A")
>        B = Symbol("B")
>        C = Symbol("C")
> 
> 
> The same program still works (and still uses "is" for identity tests,
> mind you).

But why are you using identity tests? Equality will work perfectly well, 
and won't expose the implementation detail that these objects may be 
singletons. That's especially important at the next step, when you 
replace the Symbol class with regular strings. If the caller happens to 
use "C" rather than ABC.C, why is this a problem?



-- 
Steven D'Aprano
http://import-that.dreamwidth.org/

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


#67268

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2014-03-01 00:58 +0000
Message-ID<531130b9$0$29985$c3e8da3$5496439d@news.astraweb.com>
In reply to#67259
On Sat, 01 Mar 2014 02:11:53 +0200, Marko Rauhamaa wrote:

> Ben Finney <ben+python@benfinney.id.au>:
> 
>> As has been pointed out to you, the whole point here is that string
>> objects often *are not* distinct, despite conceptually having distinct
>> cretion in the source.
> 
> You know full well that this initialization creates references to
> distinct objects:
> 
>     class ABC:
>         IDLE = "IDLE"
>         CONNECTING = "CONNECTING"
>         CONNECTED = "CONNECTED"
>         DISCONNECTING = "DISCONNECTING"
>         DISCONNECTED = "DISCONNECTED"
> 
> The 5 constants can (and should) be distinguished with the "is"
> operator. Using "==" in this case would be slightly misleading.

I disagree. You are focusing on identity, but identity is (usually) not 
important. That's an implementation detail.

What we have here is the curse of the singleton design anti-pattern:

http://accu.org/index.php/journals/337

https://molecularmusings.wordpress.com/2011/11/11/singleton-is-an-anti-pattern/

Since the symbols IDLE, CONNECTING etc. don't have state apart from their 
name, whether there is one or a million and one instances is irrelevant.


-- 
Steven

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


#67231

FromMichael Torrie <torriem@gmail.com>
Date2014-02-28 07:49 -0700
Message-ID<mailman.7475.1393600303.18130.python-list@python.org>
In reply to#67206
On 02/28/2014 01:46 AM, Ben Finney wrote:
> Steven D'Aprano <steve@pearwood.info> writes:
> 
>> On Fri, 28 Feb 2014 09:43:58 +0200, Marko Rauhamaa wrote:
>>>    class Connection:
>>>        IDLE = "IDLE"
>> [...]
>>>        CONNECTED = "CONNECTED"
>> [...]
>>>        def disconnect(self):
>>>            ...
>>>            if self.state is CONNECTED:
>>>                ...
>>
>> Why do you care that the state is *that specific* string, rather than
>> any old string with the value "CONNECTED"?
> 
> I can think of a reason:
> 
> * When you publish the API for the ‘Connection’ class,
> 
> * and another party writes code that sets ‘state’ to a string with the
>   value ‘"CONNECTED"’,
> 
> * and you implemented the check as ‘self.state == "CONNECTED"’,
> 
> * and their code works with your class and it goes into production,
> 
> * you're then not able to change the expected value without breaking
>   that party's code.

Sure.  If he replaced the line if self.state is CONNECTED with if
self.state == self.CONNECTED then he is free to change CONNECTED at any
time.  So yes, "is" is not necessary here.  Equality checking works fine.

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


#67210

FromChris Angelico <rosuav@gmail.com>
Date2014-02-28 20:00 +1100
Message-ID<mailman.7463.1393578017.18130.python-list@python.org>
In reply to#67204
On Fri, Feb 28, 2014 at 6:43 PM, Marko Rauhamaa <marko@pacujo.net> wrote:
> Here's a use case for "is" with strings (or ints):
>
>    class Connection:
>        IDLE = "IDLE"
>        CONNECTING = "CONNECTING"
>        CONNECTED = "CONNECTED"
>        DISCONNECTING = "DISCONNECTING"
>        DISCONNECTED = "DISCONNECTED"
>
> The state objects could have been defined like this:
>
>        IDLE = object()
>        CONNECTING = object()
>        CONNECTED = object()
>        DISCONNECTING = object()
>        DISCONNECTED = object()
>
> However, strings have the advantage in troubleshooting:
>
>            sys.stderr.write("state = {}\n".format(self.state))

As Ben said, strong use-case for enums (either migrate to 3.4, or
check PyPI). But here's an alternative that uses object identity
safely. (Remember, all it takes is a bit of string interning and two
equal strings could become identical.)

class enum:
    def __init__(self, desc):
        self.desc = desc
    def __repr__(self):
        return self.desc

       IDLE = enum("IDLE")
       CONNECTING = enum("CONNECTING")
       CONNECTED = enum("CONNECTED")
       DISCONNECTING = enum("DISCONNECTING")
       DISCONNECTED = enum("DISCONNECTED")

Now object identity is the right way to do things, and you can still
do the formatting just like you say; plus there's no way to
accidentally get something that seems to work.

Of course, the real enum type is far more sophisticated than that, but
the concept is the same. It's an object.

ChrisA

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


#67365

FromGrant Edwards <invalid@invalid.invalid>
Date2014-02-28 14:20 +0000
Message-ID<leq5vj$mnb$1@reader1.panix.com>
In reply to#67204
On 2014-02-28, Marko Rauhamaa <marko@pacujo.net> wrote:

> Here's a use case for "is" with strings (or ints):
>
>    class Connection:
>        IDLE = "IDLE"
>        CONNECTING = "CONNECTING"
>        CONNECTED = "CONNECTED"
>        DISCONNECTING = "DISCONNECTING"
>        DISCONNECTED = "DISCONNECTED"
>
>        def __init__(self):
>            self.state = IDLE
>
>        def connect(self, address):
>            ...
>            self.state = CONNECTING
>            ...
>
>        def disconnect(self):
>            ...
>            if self.state is CONNECTED:
>                ...

I don't really see the point.  Why won't '==' work just as well?

Are you hoping that 'is' is faster at runtime than '=='?

-- 
Grant Edwards               grant.b.edwards        Yow! Th' MIND is the Pizza
                                  at               Palace of th' SOUL
                              gmail.com            

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


#67188 — References, and avoiding use of “variable” (was: Can global variable be passed into Python function?)

FromBen Finney <ben+python@benfinney.id.au>
Date2014-02-28 13:46 +1100
SubjectReferences, and avoiding use of “variable” (was: Can global variable be passed into Python function?)
Message-ID<mailman.7450.1393555588.18130.python-list@python.org>
In reply to#67177
"Mark H. Harris" <harrismh777@gmail.com> writes:

> So, yeah, thinking about variables is just not going away.

Right. I would like, ideally, for the Python documentation to avoid
mentioning that term entirely; and I would hope for that to promote a
better understanding of Python's data model.

The wider programming community, though, will no doubt continue to use
that term to refer to various (incompatible) data models, and I
certainly don't expect the Python community to pretend it doesn't exist.

I encourage getting rid of it from Python documentation, but not getting
rid of it from discussion in the community.

> I finally decided (in my own head) that I would completely give up on
> the 'variable' concept (intellectually)  and help folks try to
> understand references and reference counting.

Reference counting isn't a concept one needs to present to newcomers,
IMO. It is sufficient to explain that the Python runtime is free to
discard an object when nothing refers to it any more.

There's no need to explain to a newcomer the garbage-collection
implementation details, precisely *because* it's an implementation
detail. Some Python implementations use reference counting, some don't,
and each implementation is free to do what it likes so long as the data
model guarantees are preserved. The user normally shouldn't care,
because they shouldn't have to depend on any specific garbage-collection
behaviour.

So: it's good to present the concept of “references”, and use “name
binding” instead of “variable”; but there's no need to present
“reference counting”, which is a Python-implementation-detail technical
concept that IMO doesn't need to be in the newcomer's head.

-- 
 \      “The trouble with the rat race is that even if you win, you're |
  `\                       still a rat.” —Jane Wagner, via Lily Tomlin |
_o__)                                                                  |
Ben Finney

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


#67223 — Re: References, and avoiding use of ???variable??? (was: Can global variable be passed into Python function?)

FromNeil Cerutti <neilc@norwich.edu>
Date2014-02-28 14:30 +0000
SubjectRe: References, and avoiding use of ???variable??? (was: Can global variable be passed into Python function?)
Message-ID<mailman.7469.1393597876.18130.python-list@python.org>
In reply to#67177
On 2014-02-28, Ben Finney <ben+python@benfinney.id.au> wrote:
> "Mark H. Harris" <harrismh777@gmail.com> writes:
>> So, yeah, thinking about variables is just not going away.
>
> Right. I would like, ideally, for the Python documentation to
> avoid mentioning that term entirely; and I would hope for that
> to promote a better understanding of Python's data model.
>
> The wider programming community, though, will no doubt continue
> to use that term to refer to various (incompatible) data
> models, and I certainly don't expect the Python community to
> pretend it doesn't exist.

I like the characteristic of Python that assignment and argument
passing work the same way. If only C were so simple!

The tutorial makes things sound more high-falutin' than that
[Tutorial 4.6 Defining Functions]:

  The actual parameters (arguments) to a function call are
  introduced in the local symbol table of the called function
  when it is called; thus, arguments are passed using call by
  value (where the value is always an object reference, not the
  value of the object). [...]

How about:

  The actual parameters (arguments) to a function call are passed
  via assignment to the variables in the local symbol table of
  the called function. 

Am I oversimplifying?

-- 
Neil Cerutti

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


#67255 — Re: References, and avoiding use of ???variable???

FromBen Finney <ben+python@benfinney.id.au>
Date2014-03-01 10:33 +1100
SubjectRe: References, and avoiding use of ???variable???
Message-ID<mailman.7482.1393630424.18130.python-list@python.org>
In reply to#67177
Neil Cerutti <neilc@norwich.edu> writes:

> On 2014-02-28, Ben Finney <ben+python@benfinney.id.au> wrote:
> > Right. I would like, ideally, for the Python documentation to
> > avoid mentioning that term entirely; and I would hope for that
> > to promote a better understanding of Python's data model.
>
> I like the characteristic of Python that assignment and argument
> passing work the same way.

Yes. They both work by binding a name to a value.

> The tutorial makes things sound more high-falutin' than that
> [Tutorial 4.6 Defining Functions]:
>
>   The actual parameters (arguments) to a function call are
>   introduced in the local symbol table of the called function
>   when it is called; thus, arguments are passed using call by
>   value (where the value is always an object reference, not the
>   value of the object). [...]
>
> How about:
>
>   The actual parameters (arguments) to a function call are passed
>   via assignment to the variables in the local symbol table of
>   the called function. 
>
> Am I oversimplifying?

As you can see by what you quoted from me above, I think the use of
“variable” here is unnecessarily confusing.

That whole chapter of the tutorial talks about “variable” and “variable
assignment”, when IMO it should avoid those terms and use the clearer
terminology of “reference”, “name”, and “binding a name to a value”.

(Why don't I submit these documentation changes myself? That's a matter
for a separate thread.)

-- 
 \         “All my life I've had one dream: to achieve my many goals.” |
  `\                                            —Homer, _The Simpsons_ |
_o__)                                                                  |
Ben Finney

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


#67285 — Re: References, and avoiding use of ???variable???

FromGregory Ewing <greg.ewing@canterbury.ac.nz>
Date2014-03-01 16:08 +1300
SubjectRe: References, and avoiding use of ???variable???
Message-ID<bnd19nF7tu5U1@mid.individual.net>
In reply to#67255
Ben Finney wrote:
> That whole chapter of the tutorial talks about “variable” and “variable
> assignment”, when IMO it should avoid those terms and use the clearer
> terminology of “reference”, “name”, and “binding a name to a value”.

What about all the other things that can be assigned
to but aren't names? (List and dict elements, attributes,
etc.) What do you suggest calling them?

-- 
Greg

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


#67288 — Re: References, and avoiding use of ???variable???

FromBen Finney <ben+python@benfinney.id.au>
Date2014-03-01 15:22 +1100
SubjectRe: References, and avoiding use of ???variable???
Message-ID<mailman.7498.1393647779.18130.python-list@python.org>
In reply to#67285
Gregory Ewing <greg.ewing@canterbury.ac.nz> writes:

> Ben Finney wrote:
> > That whole chapter of the tutorial talks about “variable” and “variable
> > assignment”, when IMO it should avoid those terms and use the clearer
> > terminology of “reference”, “name”, and “binding a name to a value”.
>
> What about all the other things that can be assigned
> to but aren't names? (List and dict elements, attributes,
> etc.) What do you suggest calling them?

Assignment binds a reference to a value.

A name is a special kind of reference.

-- 
 \     “We are all agreed that your theory is crazy. The question that |
  `\      divides us is whether it is crazy enough to have a chance of |
_o__)            being correct.” —Niels Bohr (to Wolfgang Pauli), 1958 |
Ben Finney

[toc] | [prev] | [standalone]


Page 11 of 11 — ← Prev page 1 … 9 10 [11]

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


csiph-web