Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #66792 > unrolled thread
| Started by | Sam <lightaiyee@gmail.com> |
|---|---|
| First post | 2014-02-20 22:37 -0800 |
| Last post | 2014-03-01 15:22 +1100 |
| Articles | 20 on this page of 219 — 28 participants |
Back to article view | Back to comp.lang.python
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 7 of 11 — ← Prev page 1 … 5 6 [7] 8 9 … 11 Next page →
| From | Marko Rauhamaa <marko@pacujo.net> |
|---|---|
| Date | 2014-02-28 23:03 +0200 |
| Message-ID | <87wqgfdk6a.fsf@elektro.pacujo.net> |
| In reply to | #67248 |
"Mark H. Harris" <harrismh777@gmail.com>:
> Yep, my point exactly. nice illustration.
So now, for you and me: let's compare.
if key is ast.Assign:
return ' '.join(dump(t) for t in node.targets)
elif key is ast.AugAssign:
# Same target and same operator.
return dump(node.target) + dump(node.op) + "="
elif key is ast.Return:
# A return statement is always compatible with another.
return "(easy)"
elif key is ast.Expr:
# Calling these never compatible is wrong. Calling them
# always compatible will give lots of false positives.
return "(maybe)"
else:
# These ones are never compatible, so return some
# object that's never equal to anything.
return float("nan")
vs (my proposal):
with key from ast:
if Assign:
return ' '.join(dump(t) for t in node.targets)
elif AugAssign:
# Same target and same operator.
return dump(node.target) + dump(node.op) + "="
elif Return:
# A return statement is always compatible with another.
return "(easy)"
elif Expr:
# Calling these never compatible is wrong. Calling them
# always compatible will give lots of false positives.
return "(maybe)"
else:
# These ones are never compatible, so return some
# object that's never equal to anything.
return float("nan")
Which do *you* find more readable?
Marko
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2014-02-28 21:23 +0000 |
| Message-ID | <mailman.7480.1393622633.18130.python-list@python.org> |
| In reply to | #67249 |
On 28/02/2014 21:03, Marko Rauhamaa wrote:
> "Mark H. Harris" <harrismh777@gmail.com>:
>
>> Yep, my point exactly. nice illustration.
>
> So now, for you and me: let's compare.
>
> if key is ast.Assign:
> return ' '.join(dump(t) for t in node.targets)
> elif key is ast.AugAssign:
> # Same target and same operator.
> return dump(node.target) + dump(node.op) + "="
> elif key is ast.Return:
> # A return statement is always compatible with another.
> return "(easy)"
> elif key is ast.Expr:
> # Calling these never compatible is wrong. Calling them
> # always compatible will give lots of false positives.
> return "(maybe)"
> else:
> # These ones are never compatible, so return some
> # object that's never equal to anything.
> return float("nan")
>
> vs (my proposal):
>
> with key from ast:
> if Assign:
> return ' '.join(dump(t) for t in node.targets)
> elif AugAssign:
> # Same target and same operator.
> return dump(node.target) + dump(node.op) + "="
> elif Return:
> # A return statement is always compatible with another.
> return "(easy)"
> elif Expr:
> # Calling these never compatible is wrong. Calling them
> # always compatible will give lots of false positives.
> return "(maybe)"
> else:
> # These ones are never compatible, so return some
> # object that's never equal to anything.
> return float("nan")
>
> Which do *you* find more readable?
>
>
> Marko
>
http://c2.com/cgi/wiki?SwitchStatementsSmell
--
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]
| From | Marko Rauhamaa <marko@pacujo.net> |
|---|---|
| Date | 2014-03-01 01:06 +0200 |
| Message-ID | <87sir2et1d.fsf@elektro.pacujo.net> |
| In reply to | #67250 |
Mark Lawrence <breamoreboy@yahoo.co.uk>: > http://c2.com/cgi/wiki?SwitchStatementsSmell Your brief summary, please, Mark? Anyway, the first 1000 lines or so that I managed to read from that page stated a valid principle, which however doesn't invalidate the existence of a switch statement. A colleague of mine taught me decades back that the whole point of OO was the avoidance of if and switch statements. So if your code has an if or switch statement, chances are you are doing something wrong. I agree. However, like all other maxims, that principle, too, has exceptions. Two recurring examples are parsers/decoders and state machines. Sure, you can implement states beautifully with objects/classes (and I do do that when performance is not an issue), but having experimented with different implementation techniques (in C, C++ and Java), I have concluded that switch statements are often unbeatable in performance and clarity. And I sometimes run into convoluted factory (anti)patterns whose sole purpose is to avoid straightforward switch statements in a decoder. Marko
[toc] | [prev] | [next] | [standalone]
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Date | 2014-03-01 11:02 +1100 |
| Message-ID | <mailman.7483.1393632181.18130.python-list@python.org> |
| In reply to | #67252 |
Marko Rauhamaa <marko@pacujo.net> writes: > Mark Lawrence <breamoreboy@yahoo.co.uk>: > > > http://c2.com/cgi/wiki?SwitchStatementsSmell > > Your brief summary, please, Mark? > > Anyway, the first 1000 lines or so that I managed to read from that page > stated a valid principle, which however doesn't invalidate the existence > of a switch statement. The first sentence on that page explains that it's describing a “code smell”, with a link to the page which explains that term <URL:http://c2.com/cgi/wiki?CodeSmell>. Did you read that page? A code smell is an indication that something is wrong in the code. That indication is not 100% accurate; the point is that it's accurate enough to be worth further scrutiny to find what problem may be causing the smell. > However, like all other maxims, that principle, too, has exceptions. Of course. That's the point of describing something as a “code smell”: it may have exceptions where the smell does not indicate an actual problem, but those are not the normal case where the smell is encountered. More often, it indicates a problem that should be fixed. -- \ “Members of the general public commonly find copyright rules | `\ implausible, and simply disbelieve them.” —Jessica Litman, | _o__) _Digital Copyright_ | Ben Finney
[toc] | [prev] | [next] | [standalone]
| From | Roy Smith <roy@panix.com> |
|---|---|
| Date | 2014-02-28 19:48 -0500 |
| Message-ID | <roy-1101E1.19482628022014@news.panix.com> |
| In reply to | #67257 |
In article <mailman.7483.1393632181.18130.python-list@python.org>, Ben Finney <ben+python@benfinney.id.au> wrote: > Of course. That's the point of describing something as a “code smell”: > it may have exceptions where the smell does not indicate an actual > problem, but those are not the normal case where the smell is > encountered. More often, it indicates a problem that should be fixed. An apt analogy is refrigerator smell. Sometimes it means the leftovers from 3 months ago have evolved into a sentient life form. Sometimes it just means you've got a piece of Roquefort.
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-03-01 13:00 +1100 |
| Message-ID | <mailman.7494.1393639251.18130.python-list@python.org> |
| In reply to | #67252 |
On Sat, Mar 1, 2014 at 10:06 AM, Marko Rauhamaa <marko@pacujo.net> wrote: > A colleague of mine taught me decades back that the whole point of OO > was the avoidance of if and switch statements. So if your code has an if > or switch statement, chances are you are doing something wrong. > > I agree. *boggle* Are you seriously suggesting that every condition requires the declaration of an object type? UGH! No thank you. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Roy Smith <roy@panix.com> |
|---|---|
| Date | 2014-02-28 22:15 -0500 |
| Message-ID | <roy-D097F8.22151028022014@news.panix.com> |
| In reply to | #67281 |
On Sat, Mar 1, 2014 at 10:06 AM, Marko Rauhamaa <marko@pacujo.net> wrote:
> A colleague of mine taught me decades back that the whole point of OO
> was the avoidance of if and switch statements. So if your code has an if
> or switch statement, chances are you are doing something wrong.
This sounds like a classic case of a useful observation being taken out
of context.
On of the standard mantras about OOP is that you should not "use code to
find code". By that, they mean, you should not do things like
(pseudo-code):
if type(obj) == Foo:
frobnicate_with_foo(obj)
else if type(obj_ == Bar:
frobnicate_with_bar(obj)
else:
frobnicate_with_other(obj)
But rather, you should let the class dispatch machinery handle figuring
out which version of frobnicate() to call. That's a reasonable
statement, but somehow that seems to have gotten twisted into, "If
you're doing OOP, you should never have any 'if' statements".
[toc] | [prev] | [next] | [standalone]
| From | albert@spenarnc.xs4all.nl (Albert van der Horst) |
|---|---|
| Date | 2014-03-10 14:12 +0000 |
| Message-ID | <531dc86b$0$25076$e4fe514c@dreader37.news.xs4all.nl> |
| In reply to | #67252 |
In article <87sir2et1d.fsf@elektro.pacujo.net>, Marko Rauhamaa <marko@pacujo.net> wrote: >Mark Lawrence <breamoreboy@yahoo.co.uk>: > >> http://c2.com/cgi/wiki?SwitchStatementsSmell > >Your brief summary, please, Mark? > >Anyway, the first 1000 lines or so that I managed to read from that page >stated a valid principle, which however doesn't invalidate the existence >of a switch statement. > >A colleague of mine taught me decades back that the whole point of OO >was the avoidance of if and switch statements. So if your code has an if >or switch statement, chances are you are doing something wrong. > >I agree. > >However, like all other maxims, that principle, too, has exceptions. Two >recurring examples are parsers/decoders and state machines. Sure, you >can implement states beautifully with objects/classes (and I do do that >when performance is not an issue), but having experimented with >different implementation techniques (in C, C++ and Java), I have >concluded that switch statements are often unbeatable in performance and >clarity. I can't see why parsers decoders are any different. The Pentium assembler in my ciforth's ``forth.lab'' library has not a single if statement and I reckon it is a superior design. (State is kept in an ai blackboard fashion in bitmaps.) Forth has of course a built in "look it up, then execute it", which could be regarded as a giant switch. > >And I sometimes run into convoluted factory (anti)patterns whose sole >purpose is to avoid straightforward switch statements in a decoder. > > >Marko -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
[toc] | [prev] | [next] | [standalone]
| From | Marko Rauhamaa <marko@pacujo.net> |
|---|---|
| Date | 2014-03-10 16:29 +0200 |
| Message-ID | <87k3c2rut1.fsf@elektro.pacujo.net> |
| In reply to | #68144 |
albert@spenarnc.xs4all.nl (Albert van der Horst): > I can't see why parsers decoders are any different. The Pentium > assembler in my ciforth's ``forth.lab'' library has not a single if > statement and I reckon it is a superior design. (State is kept in an > ai blackboard fashion in bitmaps.) Forth has of course a built in > "look it up, then execute it", which could be regarded as a giant > switch. Isn't this the idea of using Python dicts as hand-compiled switch statements? Marko
[toc] | [prev] | [next] | [standalone]
| From | Grant Edwards <invalid@invalid.invalid> |
|---|---|
| Date | 2014-02-28 22:00 +0000 |
| Message-ID | <ler0tk$1oo$1@reader1.panix.com> |
| In reply to | #67250 |
On 2014-02-28, Mark Lawrence <breamoreboy@yahoo.co.uk> wrote:
> http://c2.com/cgi/wiki?SwitchStatementsSmell
So lack of a switch state is an attempt to force Python programmers to
write things in an "object oriented" way?
--
Grant Edwards grant.b.edwards Yow! FUN is never having to
at say you're SUSHI!!
gmail.com
[toc] | [prev] | [next] | [standalone]
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Date | 2014-03-02 09:36 +1100 |
| Message-ID | <mailman.7546.1393713606.18130.python-list@python.org> |
| In reply to | #67366 |
Grant Edwards <invalid@invalid.invalid> writes: > On 2014-02-28, Mark Lawrence <breamoreboy@yahoo.co.uk> wrote: > > > http://c2.com/cgi/wiki?SwitchStatementsSmell > > So lack of a switch state is an attempt […] Since when is the absence of action an “attempt” to do anything? You're assuming the not-doing of something must have a purpose. That assumption doesn't seem justified. -- \ “You are welcome to visit the cemetery where famous Russian and | `\ Soviet composers, artists, and writers are buried daily except | _o__) Thursday.” —Russian orthodox monastery, Moscow | Ben Finney
[toc] | [prev] | [next] | [standalone]
| From | "Mark H. Harris" <harrismh777@gmail.com> |
|---|---|
| Date | 2014-03-01 14:50 -0800 |
| Message-ID | <e60c8b48-8e05-4f09-a0ba-00ba4fd36e4e@googlegroups.com> |
| In reply to | #67386 |
On Saturday, March 1, 2014 4:36:07 PM UTC-6, Ben Finney wrote: > Since when is the absence of action an "attempt" to do anything? > > You're assuming the not-doing of something must have a purpose. That > assumption doesn't seem justified. Correct. Argument from silence is logical fallacy; lack of motion is not the "doing" of being motionless. :)
[toc] | [prev] | [next] | [standalone]
| From | "Mark H. Harris" <harrismh777@gmail.com> |
|---|---|
| Date | 2014-02-28 15:36 -0800 |
| Message-ID | <0b414429-74ee-45dd-9465-c87e98c362f2@googlegroups.com> |
| In reply to | #67249 |
On Friday, February 28, 2014 3:03:25 PM UTC-6, Marko Rauhamaa wrote:
>
> Marko
... and between me and you, here is a snip from dmath.py from the atan(x) function:
if (n**2 < D(1)):
a = __atan__(n)
elif (n == D(1)):
a = gpi/4
elif (n == D(-1)):
a = -(gpi/4)
elif (n < D(-1)):
a = __atan__Lt_neg1__(n)
else:
a = __atan__Gt_1__(n)
This if--elif--else is not only ugly, its just not readable either, and besides that, its not elegant, nor is it humanly helpful... its does work though, and its absolutely necessary. ugh.
First, its not immediately clear what it does. Well, there isn't just one atan(x) routine, there are at least four of them, depending on whether you're a purist, and they must be selected.
Second, because of the strict intent ideology of python in the first place, I can't indent this code to make it more readable without breaking python's syntax.
Third, this is a VERY simple if elif block. More complex ones are much worse... for human reading that is...
I know its a pain in the neck, but python does need a switch statement. Is it a stubborn question? I don't really think that almost every modern computer language has a switch block because of some C paradigm. I think its because most coders find them useful, at least readable, and therefore essential.
On the other hand, I have coded many scripts and lots of commercial software that used no switch blocks at all... particularly my C++ and Java stuff.
Sooo...
[toc] | [prev] | [next] | [standalone]
| From | Marko Rauhamaa <marko@pacujo.net> |
|---|---|
| Date | 2014-03-01 02:32 +0200 |
| Message-ID | <87d2i6ep2l.fsf@elektro.pacujo.net> |
| In reply to | #67256 |
"Mark H. Harris" <harrismh777@gmail.com>: > if (n**2 < D(1)): > a = __atan__(n) > elif (n == D(1)): > a = gpi/4 > elif (n == D(-1)): > a = -(gpi/4) > elif (n < D(-1)): > a = __atan__Lt_neg1__(n) > else: > a = __atan__Gt_1__(n) Drop the outermost parentheses in the if statements. They add to the clutter. Anyway, how would you express the above in, say, Java? Marko
[toc] | [prev] | [next] | [standalone]
| From | Ned Batchelder <ned@nedbatchelder.com> |
|---|---|
| Date | 2014-02-28 19:40 -0500 |
| Message-ID | <mailman.7485.1393634419.18130.python-list@python.org> |
| In reply to | #67256 |
On 2/28/14 6:36 PM, Mark H. Harris wrote: > On Friday, February 28, 2014 3:03:25 PM UTC-6, Marko Rauhamaa wrote: >> >> Marko > > ... and between me and you, here is a snip from dmath.py from the atan(x) function: > > if (n**2 < D(1)): > a = __atan__(n) > elif (n == D(1)): > a = gpi/4 > elif (n == D(-1)): > a = -(gpi/4) > elif (n < D(-1)): > a = __atan__Lt_neg1__(n) > else: > a = __atan__Gt_1__(n) > > This if--elif--else is not only ugly, its just not readable either, and besides that, its not elegant, nor is it humanly helpful... its does work though, and its absolutely necessary. ugh. > > First, its not immediately clear what it does. Well, there isn't just one atan(x) routine, there are at least four of them, depending on whether you're a purist, and they must be selected. > > Second, because of the strict intent ideology of python in the first place, I can't indent this code to make it more readable without breaking python's syntax. > > Third, this is a VERY simple if elif block. More complex ones are much worse... for human reading that is... > > I know its a pain in the neck, but python does need a switch statement. Is it a stubborn question? I don't really think that almost every modern computer language has a switch block because of some C paradigm. I think its because most coders find them useful, at least readable, and therefore essential. I don't understand: you show an if/elif chain that cannot be expressed as a switch statement (because it uses < ), and then conclude that Python needs a switch statement? That doesn't make any sense. -- Ned Batchelder, http://nedbatchelder.com
[toc] | [prev] | [next] | [standalone]
| From | "Mark H. Harris" <harrismh777@gmail.com> |
|---|---|
| Date | 2014-02-28 17:08 -0800 |
| Message-ID | <4bd11eec-395a-4484-a991-9fabf12328e1@googlegroups.com> |
| In reply to | #67264 |
On Friday, February 28, 2014 6:40:06 PM UTC-6, Ned Batchelder wrote:
>
> I don't understand: you show an if/elif chain that cannot be expressed
> as a switch statement (because it uses < ), and then conclude that
> Python needs a switch statement? That doesn't make any sense.
>
Forgive me. I would rewrite the structure,
switch x:
case GT_1:
__atan__Gt_1__(x)
case LT_1:
__atan__Lt_1__(x)
case IS_1:
a = gpi/4
case IS_n1:
a = -gpi/4
default:
__atan__(x)
or somesuch... way better... yes, there are some issues, but all workable with some effort
marcus
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-03-01 13:01 +1100 |
| Message-ID | <mailman.7495.1393639309.18130.python-list@python.org> |
| In reply to | #67271 |
On Sat, Mar 1, 2014 at 12:08 PM, Mark H. Harris <harrismh777@gmail.com> wrote: > On Friday, February 28, 2014 6:40:06 PM UTC-6, Ned Batchelder wrote: > >> >> I don't understand: you show an if/elif chain that cannot be expressed >> as a switch statement (because it uses < ), and then conclude that >> Python needs a switch statement? That doesn't make any sense. >> > > Forgive me. I would rewrite the structure, > > switch x: > case GT_1: > __atan__Gt_1__(x) > case LT_1: > __atan__Lt_1__(x) > case IS_1: > a = gpi/4 > case IS_n1: > a = -gpi/4 > default: > __atan__(x) > > or somesuch... way better... yes, there are some issues, but all workable with some effort Does your switch construct have to handle the magic of GT_1 meaning "> 1", or do you first figure out where it falls with an if/elif tree? ChrisA
[toc] | [prev] | [next] | [standalone]
| From | "Mark H. Harris" <harrismh777@gmail.com> |
|---|---|
| Date | 2014-02-28 21:30 -0800 |
| Message-ID | <2633c4d3-e8cc-47fa-b22a-48dab2ef1a29@googlegroups.com> |
| In reply to | #67282 |
On Friday, February 28, 2014 8:01:45 PM UTC-6, Chris Angelico wrote:
>
> Does your switch construct have to handle the magic of GT_1 meaning ">
> 1", or do you first figure out where it falls with an if/elif tree?
> ChrisA
hi Chris, yeah... well think again of the switch block in C... the switch block selects a branch based on an integral number (int character) that is generally a return code from a function. The function hides all of that logic. The function runs and returns a "number" which is passed to the switch block. That number generally corresponds to a DEFINE constant at the top or in the header... so we get something really readable:
x = somefunc()
switch (x):
case: CONSTANT1
call blah blah
case: CONSTANT2
call blah blah blah
default
blah
This very same concept can work in python code too... if everyone would just agree to try. Again, how it switches is less important than does the "switch" appear readable to humans... whether its optimized or not.
Its up to the devs whether it switches on an int, a "switch object" whatever I mean by that, or on something else I have not thought about... the point is ,
... can we make something more readable to average people than large if elif else chains, or dict dispatch tables... ??
Its just a question. I know Guido thinks not... and a lot of other people too... but what if there is a third option? If we think about this hard enough there is probably a win win out there that would work/
just sayin
marcus
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-03-01 17:24 +1100 |
| Message-ID | <mailman.7502.1393655058.18130.python-list@python.org> |
| In reply to | #67293 |
On Sat, Mar 1, 2014 at 4:30 PM, Mark H. Harris <harrismh777@gmail.com> wrote:
> hi Chris, yeah... well think again of the switch block in C... the switch block selects a branch based on an integral number (int character) that is generally a return code from a function. The function hides all of that logic. The function runs and returns a "number" which is passed to the switch block. That number generally corresponds to a DEFINE constant at the top or in the header... so we get something really readable:
>
> x = somefunc()
> switch (x):
> case: CONSTANT1
> call blah blah
> case: CONSTANT2
> call blah blah blah
> default
> blah
Okay. So you'd do that to make this more readable. Here's the original:
if (n**2 < D(1)):
a = __atan__(n)
elif (n == D(1)):
a = gpi/4
elif (n == D(-1)):
a = -(gpi/4)
elif (n < D(-1)):
a = __atan__Lt_neg1__(n)
else:
a = __atan__Gt_1__(n)
Now let's see. Your code doesn't perfectly translate, so I'm having to
guess a bit here.
GT_1 = object()
LT_n1 = object()
IS_1 = object()
IS_n1 = object()
def categorize(n):
if (n**2 < D(1)):
return None
elif (n == D(1)):
return IS_1
elif (n == D(-1)):
return IS_n1
elif (n < D(-1)):
return LT_n1
else:
return GT_1
switch categorize(x):
case GT_1:
__atan__Gt_1__(x)
# Not sure which you mean, this
case LT_n1:
__atan__Lt_neg1__(x)
# or this
case LT_1:
__atan__Lt_1__(x)
# So I have both, ish.
case IS_1:
a = gpi/4
case IS_n1:
a = -gpi/4
default:
# Presumably this should be a=?
__atan__(x)
Please copy and paste this, and then edit it so the two actually do
exactly the same thing. And then, if you please [1], explain to me how
the second one is more readable. It still has the exact same if/elif
tree, because there's no other way to figure out which constant you
should have for the switch; and as well as that, it exhibits an
appalling degree of Soft Coding[2], and it's roughly three times as
much code. If you want to change anything, you potentially have to
edit three places: the list of constants at the top, the condition
function, and the switch.
This can't be your idea of readability. Show me where I'm wrong.
ChrisA
[1] Steven D'Aprano unwittingly quoted HMS Pinafore a few posts back.
I'm now doing it consciously, for I hold that (on the seas) the
expression "if you please" a particularly gentlemanly tone implants.
[2] http://thedailywtf.com/Articles/Soft_Coding.aspx
[toc] | [prev] | [next] | [standalone]
| From | "Mark H. Harris" <harrismh777@gmail.com> |
|---|---|
| Date | 2014-03-01 13:40 -0800 |
| Message-ID | <cfeaefbf-22d8-478a-8423-2d102a52a2ab@googlegroups.com> |
| In reply to | #67297 |
On Saturday, March 1, 2014 12:24:15 AM UTC-6, Chris Angelico wrote: > much code. If you want to change anything, you potentially have to > > edit three places: the list of constants at the top, the condition > > function, and the switch. > > > > This can't be your idea of readability. Show me where I'm wrong. > > > > ChrisA hi Chris, I don't think you're wrong. There are two issues for me (and one of them is not how the switch is implemented). 1) Is it easier for average users of python as a language to read switch case default, or if elif else ? 2) Would most average users concur that 'readable' means something like, "readily understandable at quick glance, or rapid preview" (or quiv). I readily admit that 'subjective' is the operative work here. As Guido found at his 2007 keynote most experienced devs are not clamoring for a switch block. Just so. But I'm not thinking of experienced devs. I'm thinking of the average coder who is used to looking at switch blocks. I personally can see and understand a switch block 2x to 3x faster than looking at an elif chain. Because I am primarily a C programmer and I personally use and read switch blocks. An experienced python dev can readily 'see' an elif chain, well, because that's all they have and that's all they look at day to day. So, naturally a python dev is going to think an elif chain is readable. Thank you sir, you have good insights. A quote from the high seas is classy. (another post with no elipses) Cheers
[toc] | [prev] | [next] | [standalone]
Page 7 of 11 — ← Prev page 1 … 5 6 [7] 8 9 … 11 Next page →
Back to top | Article view | comp.lang.python
csiph-web