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 20 on this page of 219 — 28 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? albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-03-10 14:12 +0000
                                            Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-10 16:29 +0200
                                        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 2 of 11 — ← Prev page 1 [2] 3 4 … 11  Next page →


#66883

Fromwxjmfauth@gmail.com
Date2014-02-22 00:26 -0800
Message-ID<2dab8e37-dd35-43d7-aa3f-c4936d82b478@googlegroups.com>
In reply to#66882
Le samedi 22 février 2014 09:10:02 UTC+1, Chris Angelico a écrit :
> On Sat, Feb 22, 2014 at 7:02 PM,  <wxjmfauth@gmail.com> wrote:
> 
> >>>> # a swapping variant
> 
> >>>> def swap(a, b):
> 
> > ...     ab = [a, b]
> 
> > ...     ab[1], ab[0] = ab[0], ab[1]
> 
> > ...     return ab[0], ab[1]
> 
> 
> 
> Provably identical to:
> 
> 
> 
> def swap(a, b):
> 
>     return b, a
> 
> 
> 
> The rest is just fluff.
> 
> 
> 
> ChrisA

Right. My bad, (just wake up).

jmf

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


#66884

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2014-02-22 08:28 +0000
Message-ID<53085fa1$0$29985$c3e8da3$5496439d@news.astraweb.com>
In reply to#66882
On Sat, 22 Feb 2014 19:10:02 +1100, Chris Angelico wrote:

> On Sat, Feb 22, 2014 at 7:02 PM,  <wxjmfauth@gmail.com> wrote:
>>>>> # a swapping variant
>>>>> def swap(a, b):
>> ...     ab = [a, b]
>> ...     ab[1], ab[0] = ab[0], ab[1]
>> ...     return ab[0], ab[1]
> 
> Provably identical to:
> 
> def swap(a, b):
>     return b, a
> 
> The rest is just fluff.

You don't even need the function call.

a, b = b, a


-- 
Steven

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


#66885

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2014-02-22 08:35 +0000
Message-ID<5308614c$0$29985$c3e8da3$5496439d@news.astraweb.com>
In reply to#66880
On Sat, 22 Feb 2014 18:29:02 +1100, Chris Angelico wrote:

> On Sat, Feb 22, 2014 at 6:18 PM, Steven D'Aprano
> <steve+comp.lang.python@pearwood.info> wrote:
>> Now I daresay that under the hood, Pascal is passing the address of foo
>> (or bar) to the procedure plus, but inside plus you don't see that
>> address as the value of b. You see the value of foo (or bar).
>>
>> C does not do that -- you have to manually manage the pointers
>> yourself, while Pascal does it for you. And Python also has nothing
>> like that.
> 
> Yep. I should have clarified that I wasn't talking about Pascal; I'm not
> fluent in the language (last time I did anything at all with Pascal was
> probably about ten years ago, and not much then). In C, it strictly does
> what I said: & takes the address of something, * dereferences an
> address. There's no way to "pass a variable" - you have to pass the
> address, and that has consequences if, for instance, you *return* an
> address and the variable ceases to exist. (Does Pascal have an
> equivalent of that?)

Yes, Pascal has pointers as a first-class data type. Syntax is similar to 
C, ^x is a pointer to x, p^ dereferences the pointer p.


> And Python has no such concept, anywhere. But anything that you can
> achieve in C using pointers, you can probably achieve in Python using
> more complex objects.

Not even that complex. Although Python doesn't do pointers, the model of 
the language is such that you don't need to. Where in C or Pascal you 
would pass a pointer to a record, in Python you just pass the record, 
safe in the knowledge that the entire record won't be copied.

There are a few idioms which don't work as neatly in Python as in Pascal, 
such as output parameter, but you don't need them. Just return a tuple. 
If you insist on an output parameter, do it like this:


def func(inarg, outarg):
    if inarg % 2:
        outarg[0] == "even"
    else:
        outarg[0] == "odd"
    return inarg + 1

out = [None]
x = 42

result = func(x, out)
print(out[0])


-- 
Steven

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


#66887

FromChris Angelico <rosuav@gmail.com>
Date2014-02-22 19:45 +1100
Message-ID<mailman.7256.1393058737.18130.python-list@python.org>
In reply to#66885
On Sat, Feb 22, 2014 at 7:35 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
>> Yep. I should have clarified that I wasn't talking about Pascal; I'm not
>> fluent in the language (last time I did anything at all with Pascal was
>> probably about ten years ago, and not much then). In C, it strictly does
>> what I said: & takes the address of something, * dereferences an
>> address. There's no way to "pass a variable" - you have to pass the
>> address, and that has consequences if, for instance, you *return* an
>> address and the variable ceases to exist. (Does Pascal have an
>> equivalent of that?)
>
> Yes, Pascal has pointers as a first-class data type. Syntax is similar to
> C, ^x is a pointer to x, p^ dereferences the pointer p.
>

Right, I remember those now. Yes. (See how rusty I am on it? Heh.)

ChrisA

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


#66970

FromGregory Ewing <greg.ewing@canterbury.ac.nz>
Date2014-02-24 21:07 +1300
Message-ID<bn0cufFgcbrU1@mid.individual.net>
In reply to#66885
Steven D'Aprano wrote:
> Yes, Pascal has pointers as a first-class data type. Syntax is similar to 
> C, ^x is a pointer to x, p^ dereferences the pointer p.

Actually, the prefix ^ is only used for declaring
pointer *types*. Standard Pascal has no way of getting
a pointer to an arbitrary variable; the only way to
get a pointer is new(p) (which is the equivalent of
p = malloc(sizeof(*p))).

-- 
Greg

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


#66983

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2014-02-24 15:57 +0000
Message-ID<530b6bf2$0$29985$c3e8da3$5496439d@news.astraweb.com>
In reply to#66970
On Mon, 24 Feb 2014 21:07:42 +1300, Gregory Ewing wrote:

> Steven D'Aprano wrote:
>> Yes, Pascal has pointers as a first-class data type. Syntax is similar
>> to C, ^x is a pointer to x, p^ dereferences the pointer p.
> 
> Actually, the prefix ^ is only used for declaring pointer *types*.
> Standard Pascal has no way of getting a pointer to an arbitrary
> variable; the only way to get a pointer is new(p) (which is the
> equivalent of p = malloc(sizeof(*p))).



Standard Pascal? Who uses standard Pascal? I'm talking about MacPascal :-)

Actually, it's possible that I've forgotten the details, it's been over 
twenty years since I last dereferences a Pascal pointer in anger, so you 
might be right... a quick glance at some of my text books suggest that 
you probably are. Thanks for the correction!


-- 
Steven

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


#67012

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2014-02-24 21:12 -0500
Message-ID<mailman.7334.1393294561.18130.python-list@python.org>
In reply to#66983
On 24 Feb 2014 15:57:38 GMT, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> declaimed the following:

>On Mon, 24 Feb 2014 21:07:42 +1300, Gregory Ewing wrote:
>
>> Steven D'Aprano wrote:
>>> Yes, Pascal has pointers as a first-class data type. Syntax is similar
>>> to C, ^x is a pointer to x, p^ dereferences the pointer p.
>> 
>> Actually, the prefix ^ is only used for declaring pointer *types*.
>> Standard Pascal has no way of getting a pointer to an arbitrary
>> variable; the only way to get a pointer is new(p) (which is the
>> equivalent of p = malloc(sizeof(*p))).
>
>
>
>Standard Pascal? Who uses standard Pascal? I'm talking about MacPascal :-)
>
>Actually, it's possible that I've forgotten the details, it's been over 
>twenty years since I last dereferences a Pascal pointer in anger, so you 
>might be right... a quick glance at some of my text books suggest that 
>you probably are. Thanks for the correction!

	Alcor Pascal (TRS-80, in my case) had a library function Location(),
but the value it returned could not be used as a pointer dereference. It
was mainly meant providing arguments to the interface to the assembly level
call scheme (pass the address of a structure in a Z-80 register while
calling something in the OS)
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

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


#67089

FromGregory Ewing <greg.ewing@canterbury.ac.nz>
Date2014-02-26 23:59 +1300
Message-ID<bn5volFmdq5U1@mid.individual.net>
In reply to#66983
Steven D'Aprano wrote:
> Standard Pascal? Who uses standard Pascal? I'm talking about MacPascal :-)

Mac Pascal used @ for getting a pointer to
a variable, if I remember rightly.

-- 
Greg

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


#67104

FromMRAB <python@mrabarnett.plus.com>
Date2014-02-26 18:59 +0000
Message-ID<mailman.7400.1393441154.18130.python-list@python.org>
In reply to#67089
On 2014-02-26 10:59, Gregory Ewing wrote:
> Steven D'Aprano wrote:
>> Standard Pascal? Who uses standard Pascal? I'm talking about MacPascal :-)
>
> Mac Pascal used @ for getting a pointer to
> a variable, if I remember rightly.
>
So did Turbo Pascal. Delphi, which is what Turbo Pascal became, is the
same.

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


#66877

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2014-02-22 06:57 +0000
Message-ID<53084a53$0$29985$c3e8da3$5496439d@news.astraweb.com>
In reply to#66842
On Fri, 21 Feb 2014 21:20:12 +0200, Marko Rauhamaa wrote:

> On the question of how variables can be passed to functions, C, of
> course, has the & operator and Pascal has the "var" keyword.
> 
> An analogous thing can be achieved in Python 3 (but not in Python 2, I'm
> afraid). The & operator corresponds to an ad hoc property class as in
> the program below (not intended to be serious).

I'm glad you added that comment about not being serious. But even so, 
your code is extremely unPythonic and doesn't even succeed in doing what 
you try to accomplish:


> The program demonstrates how to write a universal "swap" function that
> interchanges two references.

For the record, there is no need for such a universal swap function in 
Python, as the right way to do it is:

x, y = y, x


But your code doesn't succeed at doing what it sets out to do. If you try 
to call it like this:

py> x = 23
py> y = 42
py> swap(x, y)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 2, in swap
AttributeError: 'int' object has no attribute 'get'

not only doesn't it swap the two variables, but it raises an exception. 
Far from being a universal swap, it's merely an obfuscated function to 
swap a few hard-coded local variables.


-- 
Steven

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


#66879

FromMarko Rauhamaa <marko@pacujo.net>
Date2014-02-22 09:28 +0200
Message-ID<878ut3ehdh.fsf@elektro.pacujo.net>
In reply to#66877
Steven D'Aprano <steve+comp.lang.python@pearwood.info>:

> But your code doesn't succeed at doing what it sets out to do. If you try 
> to call it like this:
>
> py> x = 23
> py> y = 42
> py> swap(x, y)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "<stdin>", line 2, in swap
> AttributeError: 'int' object has no attribute 'get'
>
> not only doesn't it swap the two variables, but it raises an exception. 
> Far from being a universal swap, it's merely an obfuscated function to 
> swap a few hard-coded local variables.

You are calling the function wrong. Imagine the function in C. There,
you'd have to do this:

  x = 23;
  y = 42;
  swap(&x, &y);

You've left out the ampersands and gotten a "segmentation fault."

You should have done this:

   x = 23
   y = 42

   class XP:
       def get(self):
           return x
       def set(self, value):
           nonlocal x
           x = value

   class YP:
       def get(self):
           return y
       def set(self, value):
           nonlocal y
           y = value

   swap(XP(), YP())


So we can see that Python, too, can emulate the ampersand, albeit with
some effort.


Marko

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


#66886

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2014-02-22 08:45 +0000
Message-ID<5308639e$0$29985$c3e8da3$5496439d@news.astraweb.com>
In reply to#66879
On Sat, 22 Feb 2014 09:28:10 +0200, Marko Rauhamaa wrote:

> Steven D'Aprano <steve+comp.lang.python@pearwood.info>:
> 
>> But your code doesn't succeed at doing what it sets out to do. If you
>> try to call it like this:
>>
>> py> x = 23
>> py> y = 42
>> py> swap(x, y)
>> Traceback (most recent call last):
>>   File "<stdin>", line 1, in <module>
>>   File "<stdin>", line 2, in swap
>> AttributeError: 'int' object has no attribute 'get'
>>
>> not only doesn't it swap the two variables, but it raises an exception.
>> Far from being a universal swap, it's merely an obfuscated function to
>> swap a few hard-coded local variables.
> 
> You are calling the function wrong. Imagine the function in C. There,
> you'd have to do this:
[...]


Sorry, I misunderstood you. When you called it a universal swap function, 
I thought you meant a universal swap function. I didn't realise you 
intended it as a demonstration of how to emulate a C idiom using overly-
complicated Python code *wink*

If you want to emulate pointers in Python, the simplest way is to use 
lists as pseudo-pointers.

# think of ptr[0] as pointer dereferencing
# think of [value] as quasi "address of" operator
def swap(p, q):
    p[0], q[0] = q[0], p[0]

x = ["anything"]
y = ["something"]
z = [23]

swap(x, y)
swap(x, z)

print(x[0], y[0], z[0])
=> prints "23 anything something"


But why bother to write C in Python? Python makes a really bad C, and C 
makes a really bad Python.



-- 
Steven

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


#66888

FromChris Angelico <rosuav@gmail.com>
Date2014-02-22 19:54 +1100
Message-ID<mailman.7257.1393059272.18130.python-list@python.org>
In reply to#66886
On Sat, Feb 22, 2014 at 7:45 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> But why bother to write C in Python? Python makes a really bad C, and C
> makes a really bad Python.

+1.

ChrisA

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


#66859 — Python and variables (was: Can global variable be passed into Python function?)

FromBen Finney <ben+python@benfinney.id.au>
Date2014-02-22 11:13 +1100
SubjectPython and variables (was: Can global variable be passed into Python function?)
Message-ID<mailman.7242.1393028041.18130.python-list@python.org>
In reply to#66792
Ned Batchelder <ned@nedbatchelder.com> writes:

> On 2/21/14 2:23 AM, dieter wrote:
> > Sam<lightaiyee@gmail.com>  writes:
> >
> >> >I need to pass a global variable into a python function.
> > Python does not really have the concept "variable".
> >
> > What appears to be a variable is in fact only the binding of an
> > object to a name. If you assign something to a variable,
> > all you do is binding a different object to the name.
> >
>
> Man, do I hate this idea that Python has no variables.

I agree with the sentiment of you've quoted from “dieter”, above. But I
also agree with your sentiment.

I think it's misleading to use the term “variable” to describe what
Python has, because that term has an unavoidable collection of
implications in the wider programming community, and many of those
implications are plain false for Python.

I think it's misleading to claim Python “has no variables” — which is
not quite the same as what “dieter” claimed. Python has a model of
binding references to values, and the Python documentation calls these
bindings “variables” in the special case where the reference is a name.
So, in that sense, Python has variables.

> Python's variables are names bound to values.

The ideal, in my view, would be for the Python documentation to never
use the term “variable” for this concept, since it leads newcomers
predictably to false inferences that mar their understanding of Python.

The damage isn't small, since it makes a rather simple and clear concept
needlessly difficult to understand, and falsehoods learned about
Python's data model need to be carefully rooted out and repaired later
down the track.

We should, instead, consistently use “reference” and/or “binding” for
this concept, since those lead to much more accurate inferences about
what is happening.

-- 
 \      “People always ask me, ‘Where were you when Kennedy was shot?’ |
  `\                        Well, I don't have an alibi.” —Emo Philips |
_o__)                                                                  |
Ben Finney

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


#66864

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2014-02-21 21:47 -0500
Message-ID<mailman.7245.1393037249.18130.python-list@python.org>
In reply to#66792
On Fri, 21 Feb 2014 09:59:17 -0800, Travis Griggs <travisgriggs@gmail.com>
declaimed the following:

>On Feb 21, 2014, at 4:13 AM, Ned Batchelder <ned@nedbatchelder.com> wrote:
>
>> Man, do I hate this idea that Python has no variables.  It has variables (names associated with values, and the values can change over the course of the program), they just don't work the same as C or Fortran variables. In fact, they work exactly the same as Javascript or Ruby variables.
>
>Thank you!
>
>+11
>
>I get tired of the “Python doesn’t have variables” line.
>

	If one is coming from the world where "variable" means "name
identifying a fixed location in memory" then Python does not have
"variables".

	BASIC, C, FORTRAN, COBOL, Assembly... A "variable" is synonym for an
address [a box that holds things].

	Even Python's mutable types (list, dictionary, for example) do not
follow the "fixed location" metaphor. Each cell in a list merely references
some object, and assignment to that cell changes the reference, not the
object.
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

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


#66868

FromNed Batchelder <ned@nedbatchelder.com>
Date2014-02-21 22:14 -0500
Message-ID<mailman.7248.1393038871.18130.python-list@python.org>
In reply to#66792
On 2/21/14 9:47 PM, Dennis Lee Bieber wrote:
> On Fri, 21 Feb 2014 09:59:17 -0800, Travis Griggs <travisgriggs@gmail.com>
> declaimed the following:
>
>> On Feb 21, 2014, at 4:13 AM, Ned Batchelder <ned@nedbatchelder.com> wrote:
>>
>>> Man, do I hate this idea that Python has no variables.  It has variables (names associated with values, and the values can change over the course of the program), they just don't work the same as C or Fortran variables. In fact, they work exactly the same as Javascript or Ruby variables.
>>
>> Thank you!
>>
>> +11
>>
>> I get tired of the “Python doesn’t have variables” line.
>>
>
> 	If one is coming from the world where "variable" means "name
> identifying a fixed location in memory" then Python does not have
> "variables".
>
> 	BASIC, C, FORTRAN, COBOL, Assembly... A "variable" is synonym for an
> address [a box that holds things].
>
> 	Even Python's mutable types (list, dictionary, for example) do not
> follow the "fixed location" metaphor. Each cell in a list merely references
> some object, and assignment to that cell changes the reference, not the
> object.
>

So we agree: variables in Python work differently than they do in those 
languages.

If one is coming from the world where "variable" means "name bound to a 
value", then Python does have "variables".

       Javascript, Ruby, Lisp, Perl, PHP, Smalltalk, Lua, Julia... a 
"variable" is a name bound to a value.

-- 
Ned Batchelder, http://nedbatchelder.com

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


#66895

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2014-02-22 14:15 +0000
Message-ID<mailman.7262.1393078476.18130.python-list@python.org>
In reply to#66792
On 22/02/2014 02:47, Dennis Lee Bieber wrote:
> 	BASIC, C, FORTRAN, COBOL, Assembly... A "variable" is synonym for an
> address [a box that holds things].
>

In C.

int xyz = 1;

xyz is placed in a register.  What is xyz called now as it's not in memory?

-- 
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]


#66897

FromMarko Rauhamaa <marko@pacujo.net>
Date2014-02-22 16:44 +0200
Message-ID<87ppmfcimk.fsf@elektro.pacujo.net>
In reply to#66895
Mark Lawrence <breamoreboy@yahoo.co.uk>:

> On 22/02/2014 02:47, Dennis Lee Bieber wrote:
>> 	BASIC, C, FORTRAN, COBOL, Assembly... A "variable" is synonym
>> for an address [a box that holds things].
>
> In C.
>
> int xyz = 1;
>
> xyz is placed in a register. What is xyz called now as it's not in
> memory?

It's still a box, just like in Python.

The difference is that while in C, the box looks like this:

   <URL: http://www.daikudojo.org/Archive/daikusan/bob.le/20090314_dovetail_box/pics/DSC_0767.JPG>

in Python, it looks like this:

   <URL: http://www.dejavubuffet.fi/wp-content/uploads/2012/10/korurasia31.jpg>


Marko

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


#66911

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2014-02-23 01:39 +0000
Message-ID<53095145$0$29985$c3e8da3$5496439d@news.astraweb.com>
In reply to#66895
On Sat, 22 Feb 2014 14:15:22 +0000, Mark Lawrence wrote:

> On 22/02/2014 02:47, Dennis Lee Bieber wrote:
>> 	BASIC, C, FORTRAN, COBOL, Assembly... A "variable" is synonym for 
>>      an address [a box that holds things].
>>
>>
> In C.
> 
> int xyz = 1;
> 
> xyz is placed in a register.  What is xyz called now as it's not in
> memory?

Of course it is in memory, just not main memory, and it is still accessed 
via an address. It's just that the address is something equivalent to 
"Register 5" instead of "address 12345678 in RAM".

You're focusing on the wrong thing here. The distinction is not "in main 
memory" versus "in a register" (or somewhere else). The distinction is 
not *where* the value lives, but the semantics of what it means to 
associate a name with a value.

In C or Pascal-style languages, what we might call the "fixed address" 
style of variables, a variable assignment like xyz = 1 does something 
like this:

- associate the name 'xyz' with some fixed location
- stuff the value 1 into that location


In Python-style languages, what we might call the "name binding" style of 
variables, that same xyz = 1 means:

- find or create the object 1
- associate the name 'xyz' with that object


In implementations like Jython and IronPython, the object is even free to 
move in memory while in use. But that's not the only difference. The big 
difference is that in "fixed location" languages, it makes sense to talk 
about the address of a *variable*. In C, you might ask for &xyz and get 
123456 regardless of whether xyz is assigned the value 1, or 23, or 999. 
But in Python, you can't ask for the address of a variable, only of the 
address of an *object* (and even that is useless to you, as you can't do 
anything with that address).




-- 
Steven

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


#66912

FromChris Angelico <rosuav@gmail.com>
Date2014-02-23 12:50 +1100
Message-ID<mailman.7271.1393120230.18130.python-list@python.org>
In reply to#66911
On Sun, Feb 23, 2014 at 12:39 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> In C or Pascal-style languages, what we might call the "fixed address"
> style of variables, a variable assignment like xyz = 1 does something
> like this:
>
> - associate the name 'xyz' with some fixed location
> - stuff the value 1 into that location

Kinda. In its purest sense, C is like that. When you declare "int
xyz;", the compiler allocates one machine word of space either in the
data segment (if that's at top level, or is declared static) or on the
stack (if it's local), and records that the name xyz points there. But
an optimizing C compiler is allowed to do what it likes, as long as it
maintains that name binding... and as long as any recorded address of
it remains valid. It's actually very similar to what was discussed in
another thread recently about PyPy and the id() function - the
compiler's free to have xyz exist in different places, or not exist at
all, as long as the program can't tell the difference. I don't know
whether PyPy allocates an id for everything or only when you call
id(), but if the latter, then it's exactly the same as a C compiler
with the address-of operator - if you never take the address, it
doesn't have to have one (and even if you do, it's free to fiddle with
things, unless you declare the variable volatile).

So, these days, C is becoming more like Python.

ChrisA

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


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

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


csiph-web