Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #71001 > unrolled thread
| Started by | Ned Batchelder <ned@nedbatchelder.com> |
|---|---|
| First post | 2014-05-06 21:19 -0400 |
| Last post | 2014-05-08 10:47 -0400 |
| Articles | 20 on this page of 155 — 34 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: The “does Python have variables?” debate Ned Batchelder <ned@nedbatchelder.com> - 2014-05-06 21:19 -0400
Re: The “does Python have variables?” debate Marko Rauhamaa <marko@pacujo.net> - 2014-05-07 09:18 +0300
Re: The “does Python have variables?” debate Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-05-07 09:51 +0100
Re: The “does Python have variables?” debate Ethan Furman <ethan@stoneleaf.us> - 2014-05-07 06:00 -0700
Re: The “does Python have variables?” debate Marko Rauhamaa <marko@pacujo.net> - 2014-05-07 17:17 +0300
Re: The “does Python have variables?” debate Chris Angelico <rosuav@gmail.com> - 2014-05-08 00:30 +1000
Re: The “does Python have variables?” debate Chris Angelico <rosuav@gmail.com> - 2014-05-08 00:14 +1000
Re: The “does Python have variables?” debate Marko Rauhamaa <marko@pacujo.net> - 2014-05-07 17:20 +0300
Re: The “does Python have variables?” debate Jerry Hill <malaclypse2@gmail.com> - 2014-05-07 11:48 -0400
Re: The “does Python have variables?” debate Mark H Harris <harrismh777@gmail.com> - 2014-05-07 14:31 -0500
Re: The “does Python have variables?” debate Ben Finney <ben@benfinney.id.au> - 2014-05-08 05:57 +1000
Re: The “does Python have variables?” debate Marko Rauhamaa <marko@pacujo.net> - 2014-05-08 00:15 +0300
Re: The “does Python have variables?” debate Mark H Harris <harrismh777@gmail.com> - 2014-05-07 16:35 -0500
Re: The “does Python have variables?” debate Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-08 01:27 +0000
Re: The “does Python have variables?” debate Chris Angelico <rosuav@gmail.com> - 2014-05-08 12:09 +1000
Re: The “does Python have variables?” debate Steven D'Aprano <steve@pearwood.info> - 2014-05-08 03:41 +0000
Re: The “does Python have variables?” debate Dan Sommers <dan@tombstonezero.net> - 2014-05-08 03:43 +0000
Re: The “does Python have variables?” debate Mark H Harris <harrismh777@gmail.com> - 2014-05-09 17:34 -0500
Re: The “does Python have variables?” debate Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-10 01:11 +0000
Re: The “does Python have variables?” debate Larry Hudson <orgnut@yahoo.com> - 2014-05-10 00:46 -0700
Re: The “does Python have variables?” debate Ben Finney <ben@benfinney.id.au> - 2014-05-08 10:35 +1000
Re: The “does Python have variables?” debate Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-08 01:32 +0000
Re: The “does Python have variables?” debate Marko Rauhamaa <marko@pacujo.net> - 2014-05-08 09:19 +0300
Re: The “does Python have variables?” debate Ben Finney <ben@benfinney.id.au> - 2014-05-08 16:40 +1000
Re: The "does Python have variables?" debate Rustom Mody <rustompmody@gmail.com> - 2014-05-07 23:50 -0700
Re: The "does Python have variables?" debate Marko Rauhamaa <marko@pacujo.net> - 2014-05-08 10:03 +0300
Re: The “does Python have variables?” debate Ned Batchelder <ned@nedbatchelder.com> - 2014-05-07 21:33 -0400
Re: The “does Python have variables?” debate Johannes Schneider <johannes.schneider@galileo-press.de> - 2014-05-08 09:26 +0200
Re: The “does Python have variables?” debate Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-09 00:54 +0000
Re: The “does Python have variables?” debate Joseph Martinot-Lagarde <joseph.martinot-lagarde@m4x.org> - 2014-05-08 10:07 +0200
Re: The “does Python have variables?” debate Chris Angelico <rosuav@gmail.com> - 2014-05-08 18:14 +1000
Re: The “does Python have variables?” debate Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-08 13:22 +0000
Re: The “does Python have variables?” debate Ben Finney <ben@benfinney.id.au> - 2014-05-08 18:34 +1000
Re: The “does Python have variables?” debate Marko Rauhamaa <marko@pacujo.net> - 2014-05-08 12:43 +0300
Re: The “does Python have variables?” debate Ben Finney <ben@benfinney.id.au> - 2014-05-08 21:14 +1000
Re: The “does Python have variables?” debate Marko Rauhamaa <marko@pacujo.net> - 2014-05-08 15:01 +0300
Re: The “does Python have variables?” debate Ben Finney <ben@benfinney.id.au> - 2014-05-09 05:14 +1000
Re: The “does Python have variables?” debate Ethan Furman <ethan@stoneleaf.us> - 2014-05-08 14:50 -0700
Re: The “does Python have variables?” debate Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-09 00:02 +0000
Re: The � debate Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-05-09 13:10 +1200
Re: The � debate Ben Finney <ben@benfinney.id.au> - 2014-05-09 13:13 +1000
Re: The � debate Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-10 01:34 +0000
Re: The � debate Mark H Harris <harrismh777@gmail.com> - 2014-05-09 21:34 -0500
Re: The � debate Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-05-10 17:58 +1200
Re: The � debate Chris Angelico <rosuav@gmail.com> - 2014-05-10 17:10 +1000
Re: The � debate Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-10 07:48 +0000
Re: The � debate Chris Angelico <rosuav@gmail.com> - 2014-05-10 18:01 +1000
Re: The � debate Marko Rauhamaa <marko@pacujo.net> - 2014-05-10 11:21 +0300
Re: The � debate Rustom Mody <rustompmody@gmail.com> - 2014-05-10 02:05 -0700
Re: The � debate Ethan Furman <ethan@stoneleaf.us> - 2014-05-10 12:30 -0700
Re: The � debate Marko Rauhamaa <marko@pacujo.net> - 2014-05-10 11:18 +0300
Re: The � debate Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-10 09:31 +0000
Re: The “does Python have variables?” debate Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-08 13:18 +0000
Re: The “does Python have variables?” debate Chris Angelico <rosuav@gmail.com> - 2014-05-08 23:46 +1000
Re: The “does Python have variables?” debate Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-08 14:22 +0000
Re: The “does Python have variables?” debate Chris Angelico <rosuav@gmail.com> - 2014-05-09 00:51 +1000
Re: The “does Python have variables?” debate Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-08 16:04 +0000
Re: The “does Python have variables?” debate Chris Angelico <rosuav@gmail.com> - 2014-05-09 02:10 +1000
Re: The “does Python have variables?” debate Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-05-08 21:02 -0400
Re: The “does Python have variables?” debate Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-09 01:32 +0000
Re: The “does Python have variables?” debate Roy Smith <roy@panix.com> - 2014-05-08 22:21 -0400
Re: The “does Python have variables?” debate Chris Angelico <rosuav@gmail.com> - 2014-05-09 12:31 +1000
Re: The "does Python have variables?" debate Rustom Mody <rustompmody@gmail.com> - 2014-05-08 22:40 -0700
Re: The "does Python have variables?" debate Chris Angelico <rosuav@gmail.com> - 2014-05-09 15:51 +1000
Re: The "does Python have variables?" debate Rustom Mody <rustompmody@gmail.com> - 2014-05-09 07:09 -0700
Re: The "does Python have variables?" debate Chris Angelico <rosuav@gmail.com> - 2014-05-10 00:29 +1000
Re: The "does Python have variables?" debate Rustom Mody <rustompmody@gmail.com> - 2014-05-09 09:07 -0700
Re: The “does Python have variables?â€瑩 debate Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-05-09 19:51 -0400
Re: The “does Python have variables?â€瑩 debate Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-05-10 01:03 +0100
Fortran (Was: The "does Python have variables?" debate) Roy Smith <roy@panix.com> - 2014-05-10 09:42 -0400
Re: Fortran (Was: The "does Python have variables?" debate) Terry Reedy <tjreedy@udel.edu> - 2014-05-10 14:31 -0400
Re: Fortran (Was: The "does Python have variables?" debate) Mark H Harris <harrismh777@gmail.com> - 2014-05-11 01:17 -0500
Re: Fortran (Was: The "does Python have variables?" debate) Rustom Mody <rustompmody@gmail.com> - 2014-05-11 00:01 -0700
Re: Fortran (Was: The "does Python have variables?" debate) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-11 07:09 +0000
Re: Fortran (Was: The "does Python have variables?" debate) Tomasz Rola <rtomek@ceti.pl> - 2014-05-11 18:09 +0200
Re: Fortran Marko Rauhamaa <marko@pacujo.net> - 2014-05-11 19:27 +0300
Re: Fortran Roy Smith <roy@panix.com> - 2014-05-11 13:51 -0400
Re: Fortran Chris Angelico <rosuav@gmail.com> - 2014-05-12 04:08 +1000
Re: Fortran Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-11 23:51 +0000
Re: Fortran Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-05-12 01:27 +0100
Re: Fortran Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-12 02:28 +0000
Re: Fortran Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-05-12 10:05 +0100
Re: Fortran Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-05-12 20:52 -0400
Re: Fortran Ethan Furman <ethan@stoneleaf.us> - 2014-05-11 11:05 -0700
Re: Fortran Chris Angelico <rosuav@gmail.com> - 2014-05-12 04:33 +1000
Re: Fortran Roy Smith <roy@panix.com> - 2014-05-11 14:43 -0400
Re: Fortran Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-11 23:15 +0000
Re: Fortran MRAB <python@mrabarnett.plus.com> - 2014-05-12 00:51 +0100
Re: Fortran Roy Smith <roy@panix.com> - 2014-05-11 20:14 -0400
Re: Fortran alister <alister.nospam.ware@ntlworld.com> - 2014-05-12 14:14 +0000
Re: Fortran Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-12 01:11 +0000
Re: Fortran Dave Angel <d@davea.name> - 2014-05-11 23:27 -0400
Re: Fortran Grant Edwards <invalid@invalid.invalid> - 2014-05-12 14:07 +0000
Re: Fortran Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-05-11 21:12 -0400
Re: Fortran (Was: The "does Python have variables?" debate) Chris Angelico <rosuav@gmail.com> - 2014-05-12 02:42 +1000
Re: Fortran Tomasz Rola <rtomek@ceti.pl> - 2014-05-11 20:04 +0200
Re: Fortran Chris Angelico <rosuav@gmail.com> - 2014-05-12 04:12 +1000
Re: Fortran (Was: The "does Python have variables?" debate) Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2014-05-11 19:05 +0200
Re: Fortran (Was: The "does Python have variables?" debate) Mark H Harris <harrismh777@gmail.com> - 2014-05-11 13:54 -0500
Re: Fortran (Was: The "does Python have variables?" debate) Chris Angelico <rosuav@gmail.com> - 2014-05-12 04:59 +1000
Re: Fortran (Was: The "does Python have variables?" debate) Mark H Harris <harrismh777@gmail.com> - 2014-05-11 14:14 -0500
Re: Fortran (Was: The "does Python have variables?" debate) albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-05-29 14:06 +0000
Re: Fortran (Was: The "does Python have variables?" debate) Peter Pearson <ppearson@nowhere.invalid> - 2014-05-29 17:53 +0000
Re: Fortran (Was: The "does Python have variables?" debate) Dave Angel <davea@davea.name> - 2014-05-11 23:10 -0400
Re: Fortran (Was: The "does Python have variables?" debate) Mark H Harris <harrismh777@gmail.com> - 2014-05-11 23:10 -0500
Re: Fortran (Was: The "does Python have variables?" debate) Mark H Harris <harrismh777@gmail.com> - 2014-05-11 23:26 -0500
Re: Fortran (Was: The "does Python have variables?" debate) Chris Angelico <rosuav@gmail.com> - 2014-05-12 14:53 +1000
Re: Fortran (Was: The "does Python have variables?" debate) Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2014-05-12 10:44 +0200
Re: Fortran (Was: The "does Python have variables?" debate) Mark H Harris <harrismh777@gmail.com> - 2014-05-13 00:33 -0500
Re: Fortran (Was: The "does Python have variables?" debate) Steven D'Aprano <steve@pearwood.info> - 2014-05-13 05:48 +0000
Re: Fortran (Was: The "does Python have variables?" debate) Mark H Harris <harrismh777@gmail.com> - 2014-05-13 00:55 -0500
Re: Fortran (Was: The "does Python have variables?" debate) Chris Angelico <rosuav@gmail.com> - 2014-05-13 15:56 +1000
Re: Fortran (Was: The "does Python have variables?" debate) Steven D'Aprano <steve@pearwood.info> - 2014-05-13 09:34 +0000
Re: Fortran (Was: The "does Python have variables?" debate) Chris Angelico <rosuav@gmail.com> - 2014-05-13 20:00 +1000
Re: Fortran (Was: The "does Python have variables?" debate) Rustom Mody <rustompmody@gmail.com> - 2014-05-13 03:44 -0700
Re: Fortran (Was: The "does Python have variables?" debate) Chris Angelico <rosuav@gmail.com> - 2014-05-13 20:50 +1000
Re: Fortran (Was: The "does Python have variables?" debate) Gene Heskett <gheskett@wdtv.com> - 2014-05-13 02:31 -0400
Re: Fortran (Was: The "does Python have variables?" debate) Steven D'Aprano <steve@pearwood.info> - 2014-05-13 07:22 +0000
Re: Fortran (Was: The "does Python have variables?" debate) Roy Smith <roy@panix.com> - 2014-05-13 07:16 -0400
Re: Fortran (Was: The "does Python have variables?" debate) Chris Angelico <rosuav@gmail.com> - 2014-05-13 21:21 +1000
Re: Fortran (Was: The "does Python have variables?" debate) Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-05-13 14:42 +0100
Re: Fortran (Was: The "does Python have variables?" debate) Gene Heskett <gheskett@wdtv.com> - 2014-05-13 07:42 -0400
Re: Fortran Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2014-05-13 19:33 +0200
Re: Fortran Marko Rauhamaa <marko@pacujo.net> - 2014-05-13 22:57 +0300
Re: Fortran Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-14 00:10 +0000
Re: Fortran Ian Kelly <ian.g.kelly@gmail.com> - 2014-05-13 21:43 -0600
Re: Fortran Marko Rauhamaa <marko@pacujo.net> - 2014-05-14 07:35 +0300
Re: Fortran Steven D'Aprano <steve@pearwood.info> - 2014-05-14 06:58 +0000
Re: Fortran Marko Rauhamaa <marko@pacujo.net> - 2014-05-14 11:46 +0300
Re: Fortran Sturla Molden <sturla.molden@gmail.com> - 2014-05-14 23:05 +0000
struct.unpack: why 's' fmt char convert to bytestring GuoChao <cx63@outlook.com> - 2014-05-15 20:34 +0800
Re: struct.unpack: why 's' fmt char convert to bytestring Dave Angel <davea@davea.name> - 2014-05-15 09:49 -0400
Re: struct.unpack: why 's' fmt char convert to bytestring MRAB <python@mrabarnett.plus.com> - 2014-05-15 15:47 +0100
Re: Fortran Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2014-05-14 15:13 +0200
Re: Fortran albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-05-29 14:26 +0000
Re: Fortran Marko Rauhamaa <marko@pacujo.net> - 2014-05-29 17:50 +0300
Re: Fortran Chris Angelico <rosuav@gmail.com> - 2014-05-30 00:58 +1000
Re: Fortran Marko Rauhamaa <marko@pacujo.net> - 2014-05-29 18:09 +0300
Re: Fortran Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-29 17:57 +0000
Re: Fortran Marko Rauhamaa <marko@pacujo.net> - 2014-05-29 21:55 +0300
Re: The “does Python have variables?” debate Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-05-09 09:13 +0100
Re: The “does Python have variables?” debate Michael Torrie <torriem@gmail.com> - 2014-05-08 08:06 -0600
Re: The “does Python have variables?” debate Chris Angelico <rosuav@gmail.com> - 2014-05-09 00:13 +1000
Re: The “does Python have variables?” debate Terry Reedy <tjreedy@udel.edu> - 2014-05-08 15:21 -0400
Re: The “does Python have variables?” debate Marko Rauhamaa <marko@pacujo.net> - 2014-05-08 23:06 +0300
Re: The “does Python have variables?” debate Ethan Furman <ethan@stoneleaf.us> - 2014-05-08 15:36 -0700
Re: The “does Python have variables?” debate Ethan Furman <ethan@stoneleaf.us> - 2014-05-08 17:05 -0700
Re: The “does Python have variables?” debate Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-05-09 01:47 +0100
Re: The “does Python have variables?” debate Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-08 00:57 +0000
Re: The “does Python have variables?” debate Roy Smith <roy@panix.com> - 2014-05-08 08:41 -0400
Re: The “does Python have variables?” debate Chris Angelico <rosuav@gmail.com> - 2014-05-08 22:54 +1000
Re: The “does Python have variables?” debate Ethan Furman <ethan@stoneleaf.us> - 2014-05-08 06:18 -0700
Re: The “does Python have variables?” debate Marko Rauhamaa <marko@pacujo.net> - 2014-05-08 17:03 +0300
Re: The “does Python have variables?” debate Ethan Furman <ethan@stoneleaf.us> - 2014-05-08 16:09 -0700
Re: The “does Python have variables?” debate "Neil D. Cerutti" <neilc@norwich.edu> - 2014-05-08 10:47 -0400
Page 1 of 8 [1] 2 3 4 5 6 7 8 Next page →
| From | Ned Batchelder <ned@nedbatchelder.com> |
|---|---|
| Date | 2014-05-06 21:19 -0400 |
| Subject | Re: The “does Python have variables?” debate |
| Message-ID | <mailman.9722.1399425590.18130.python-list@python.org> |
On 5/6/14 7:55 PM, Ben Finney wrote: > Ned Batchelder <ned@nedbatchelder.com> writes: > >> This meme bugs me so much. Python has variables. They work differently >> than variables in C. > > Which is why it's useful to intervene right at the start when someone > comes in with assumptions about “variables”; it's better that they > discard that baggage and learn about reference binding, instead. Where do you draw the line? Python ints work differently than C ints, but we don't seem to mind using the same word for them. Same for strings and functions. Python's classes work differently than C++ or Java's, but we don't say that Python has no classes. And let's not discuss Lisp's lists, Haskell's functions, or Modula-2's modules. So many terms are used and re-used, and each language has differences. Why is "variable" sacrosanct and can only be used to describe C semantics, but we're OK reusing class, int, and function? > >> In fact, they work by having names bound to values. > > My position is that this concept is sufficiently different to what most > newcomers to Python mean by “variable” (those who have the term at all; > and for those who don't, no need to introduce potentially-confusing > terms) that it's better to avoid that term entirely and immediately use > more-accurate terminology. > >> If you want to insist that Python has no variables, you will have to >> also say that neither do Javascript, Ruby, Java, PHP, etc. > > I don't know enough Ruby to comment there. For Java, Javascript, PHP, > they *do* have variables that work pretty much as expected by these > newcomers: the variables are declared and exist before a value is > assigned, they have the “box containing a value” conceptual model (as > contrasted with Python's “value with sticky-notes attached” model), the > “how do I pass by reference or by value?” question is meaningful — all > of these are significantly different in Python, so the term “variable” > is useful in those other languages but mostly just a confusing obstacle > in learning Python. As Chris A. has pointed out, Javascript works like Python, and not much like C. > >> And if Javascript has no variables, what does the var keyword mean? > > Exactly; JavaScript *does* have variables, in the ways Python does not. > -- Ned Batchelder, http://nedbatchelder.com
[toc] | [next] | [standalone]
| From | Marko Rauhamaa <marko@pacujo.net> |
|---|---|
| Date | 2014-05-07 09:18 +0300 |
| Message-ID | <8738gmxgay.fsf@elektro.pacujo.net> |
| In reply to | #71001 |
Ned Batchelder <ned@nedbatchelder.com>: > Why is "variable" sacrosanct and can only be used to describe C > semantics, but we're OK reusing class, int, and function? The Python language specification calls them variables; the terminology discussion should end there. The complaint against variables seems to hinge on the fact that Python variables are not first-class objects. A manifestation of that is that you can't pass variables by reference to functions. Actually, while Python variables are not first-class objects, one could see them as dictionary-key pairs. So you can even pass them by reference by passing the dictionary and the key. Then the problem is lists. You can't represent a list element as a dictionary-key pair. Or can you? A list can be viewed as a "dictionary" whose key is an integer. Thus, the same pass-by-reference technique would work for lists as well. Marko
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2014-05-07 09:51 +0100 |
| Message-ID | <mailman.9729.1399452731.18130.python-list@python.org> |
| In reply to | #71007 |
On 07/05/2014 07:18, Marko Rauhamaa wrote: > Ned Batchelder <ned@nedbatchelder.com>: > >> Why is "variable" sacrosanct and can only be used to describe C >> semantics, but we're OK reusing class, int, and function? > > The Python language specification calls them variables; the terminology > discussion should end there. > I entirely agree. This discussion has been done to death an infinite number of times. It fits into my "I couldn't care less" category, I just want to write code. -- 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 | Ethan Furman <ethan@stoneleaf.us> |
|---|---|
| Date | 2014-05-07 06:00 -0700 |
| Message-ID | <mailman.9733.1399470412.18130.python-list@python.org> |
| In reply to | #71007 |
On 05/06/2014 11:18 PM, Marko Rauhamaa wrote: > > Actually, while Python variables are not first-class objects, one could > see them as dictionary-key pairs. So you can even pass them by reference > by passing the dictionary and the key. Well, you could pass them that way, but not necessarily change them: --> def func1(): ... a = 1 ... b = 2 ... swap(locals(), 'a', 'b') ... print a ... print b ... --> def swap(d, key1, key2): ... print d[key1], d[key2] ... d[key1], d[key2] = d[key2], d[key1] ... print d[key1], d[key2] ... --> func1() 1 2 2 1 1 2 -- ~Ethan~
[toc] | [prev] | [next] | [standalone]
| From | Marko Rauhamaa <marko@pacujo.net> |
|---|---|
| Date | 2014-05-07 17:17 +0300 |
| Message-ID | <87r445hdvw.fsf@elektro.pacujo.net> |
| In reply to | #71019 |
Ethan Furman <ethan@stoneleaf.us>: > On 05/06/2014 11:18 PM, Marko Rauhamaa wrote: >> Actually, while Python variables are not first-class objects, one >> could see them as dictionary-key pairs. So you can even pass them by >> reference by passing the dictionary and the key. > > Well, you could pass them that way, but not necessarily change them: Weird. Some other tests of mine did work. But: Note: The contents of this dictionary should not be modified; changes may not affect the values of local and free variables used by the interpreter. [<URL: https://docs.python.org/2/library/functions.html#locals>] Marko
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-05-08 00:30 +1000 |
| Message-ID | <mailman.9735.1399473032.18130.python-list@python.org> |
| In reply to | #71022 |
On Thu, May 8, 2014 at 12:17 AM, Marko Rauhamaa <marko@pacujo.net> wrote: > Weird. Some other tests of mine did work. But: > > Note: The contents of this dictionary should not be modified; changes > may not affect the values of local and free variables used by the > interpreter. [<URL: > https://docs.python.org/2/library/functions.html#locals>] If you test locals() at module level (including the interactive interpreter), things will work, because it just returns the same dict as globals() returns. It's only inside an actual function that it's different and magical. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-05-08 00:14 +1000 |
| Message-ID | <mailman.9734.1399472070.18130.python-list@python.org> |
| In reply to | #71007 |
On Wed, May 7, 2014 at 11:00 PM, Ethan Furman <ethan@stoneleaf.us> wrote: > On 05/06/2014 11:18 PM, Marko Rauhamaa wrote: >> >> Actually, while Python variables are not first-class objects, one could >> see them as dictionary-key pairs. So you can even pass them by reference >> by passing the dictionary and the key. > > > Well, you could pass them that way, but not necessarily change them: > [ chomp demo code using locals() ] That's because, while you can *think of* Python name bindings as being like dict key/value pairs, they aren't always that. Function locals, class locals, and other such namespaces aren't necessarily implemented with dicts. They're conceptually still a "dictionary" of sorts, but you can't actually pass anyone a dict and key and expect it to work. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Marko Rauhamaa <marko@pacujo.net> |
|---|---|
| Date | 2014-05-07 17:20 +0300 |
| Message-ID | <87mwethdqr.fsf@elektro.pacujo.net> |
| In reply to | #71021 |
Chris Angelico <rosuav@gmail.com>: > That's because, while you can *think of* Python name bindings as being > like dict key/value pairs, they aren't always that. Function locals, > class locals, and other such namespaces aren't necessarily implemented > with dicts. They're conceptually still a "dictionary" of sorts, but > you can't actually pass anyone a dict and key and expect it to work. I see that as a glitch in the Matrix. Marko
[toc] | [prev] | [next] | [standalone]
| From | Jerry Hill <malaclypse2@gmail.com> |
|---|---|
| Date | 2014-05-07 11:48 -0400 |
| Message-ID | <mailman.9742.1399477705.18130.python-list@python.org> |
| In reply to | #71007 |
On Wed, May 7, 2014 at 2:18 AM, Marko Rauhamaa <marko@pacujo.net> wrote: > Ned Batchelder <ned@nedbatchelder.com>: > >> Why is "variable" sacrosanct and can only be used to describe C >> semantics, but we're OK reusing class, int, and function? > > The Python language specification calls them variables; the terminology > discussion should end there. Personally, I found the idea that a python variable is a name + value pairing to be useful when learning the language, especially when I was struggling with the calling semantics (that is, the differences between call-by-value, call-by-reference, and call-by-object). I think it's rather silly for someone to insist that python doesn't have variables. On the other hand, I think it can be useful to point out that python variable aren't like C variables, and that thinking of python variables as having two parts -- names and values -- really can help people who are struggling to learn the language. I know it certainly helped me. -- Jerry
[toc] | [prev] | [next] | [standalone]
| From | Mark H Harris <harrismh777@gmail.com> |
|---|---|
| Date | 2014-05-07 14:31 -0500 |
| Message-ID | <lke1lt$3ka$1@speranza.aioe.org> |
| In reply to | #71036 |
On 5/7/14 10:48 AM, Jerry Hill wrote: > I think it's rather silly for someone to insist that python doesn't have > variables. On the other hand, I think it can be useful to point out > that python variable aren't like C variables, and that thinking of > python variables as having two parts -- names and values -- really can > help people who are struggling to learn the language. I know it > certainly helped me. > But here is the rub: BASIC also has -- names and values --; although they are in a variable table, and they refer to memory not objects. C is the same, basically. ehem. ... a name bound to an address that references a chunk of memory (by type) of a certain length. ... and we could go on. But, Python's names bound to objects not only doesn't behave like the 'variables' mentioned above, they provide for serious side-effects for the programmer if the coder does not think of them properly as names bound to objects. And that means surprises. So, when anyone points out that Python does not have variables, but rather Python has names bound to objects... they are being most helpful. As I pointed out earlier, I think the better approach would be to find positive language for helping new folks understand Python's beautiful heart, than the relatively negative language of stating Python has no variables.
[toc] | [prev] | [next] | [standalone]
| From | Ben Finney <ben@benfinney.id.au> |
|---|---|
| Date | 2014-05-08 05:57 +1000 |
| Message-ID | <mailman.9749.1399492684.18130.python-list@python.org> |
| In reply to | #71048 |
Mark H Harris <harrismh777@gmail.com> writes: > So, when anyone points out that Python does not have variables, but > rather Python has names bound to objects... they are being most > helpful. > > As I pointed out earlier, I think the better approach would be to find > positive language for helping new folks understand Python's beautiful > heart, than the relatively negative language of stating Python has no > variables. You are implying a dichotomy which I don't think is useful: that providing accurate models is “a better approach” than pointing out existing fallacies. Rather, the better approach IMO is to use *both*: point out existing fallacies *and* replace them with more accurate models. That's why I always try to say “Python doesn't have variables the way you might know from many other languages”, *and* say “instead, it has references bound to objects” — *in the same message*. Negative, to point out the fallacy; positive, to provide the replacement. Presenting an accurate model is valuable, but it's much less valuable in isolation than pointing out that the accurate model *is superior to*, and should replace, the existing less-accurate model in the receiver's brain. One must necessarily use negative language to achieve that. -- \ “Religious faith is the one species of human ignorance that | `\ will not admit of even the *possibility* of correction.” —Sam | _o__) Harris, _The End of Faith_, 2004 | Ben Finney
[toc] | [prev] | [next] | [standalone]
| From | Marko Rauhamaa <marko@pacujo.net> |
|---|---|
| Date | 2014-05-08 00:15 +0300 |
| Message-ID | <87tx91warf.fsf@elektro.pacujo.net> |
| In reply to | #71051 |
Ben Finney <ben@benfinney.id.au>: > That's why I always try to say “Python doesn't have variables the way > you might know from many other languages”, Please elaborate. To me, Python variables are like variables in all programming languages I know. Python currently does not allow me to obtain the "address" of a variable, but that doesn't make me think of Python variables any differently. Marko
[toc] | [prev] | [next] | [standalone]
| From | Mark H Harris <harrismh777@gmail.com> |
|---|---|
| Date | 2014-05-07 16:35 -0500 |
| Message-ID | <lke8u0$mkm$1@speranza.aioe.org> |
| In reply to | #71054 |
On 5/7/14 4:15 PM, Marko Rauhamaa wrote:
>> That's why I always try to say “Python doesn't have variables the way
>> you might know from many other languages”,
>
> Please elaborate. To me, Python variables are like variables in all
> programming languages I know. Python currently does not allow me to
> obtain the "address" of a variable, but that doesn't make me think of
> Python variables any differently.
Here is the difference... in almost every other language you know.
A = macTruck
B = A
In almost every other language you know A and B each "contain" by
reference (and almost always by static type) macTruck. But NOT python.
A --> {macTruck} <-- B
In almost every other language you know there is some kind of binding
table (name reference to type/length) and BOTH A and B are bound to data
in memory macTruck... and usually its a different place in memory!
NOT python.
No doubt you may use A and B in python the way other people use their
variables in their language... but it MEANS something different.
marcus
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2014-05-08 01:27 +0000 |
| Message-ID | <536add6b$0$29965$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #71056 |
On Wed, 07 May 2014 16:35:00 -0500, Mark H Harris wrote: > On 5/7/14 4:15 PM, Marko Rauhamaa wrote: >>> That's why I always try to say “Python doesn't have variables the way >>> you might know from many other languages”, >> >> Please elaborate. To me, Python variables are like variables in all >> programming languages I know. Python currently does not allow me to >> obtain the "address" of a variable, but that doesn't make me think of >> Python variables any differently. > > Here is the difference... in almost every other language you know. How do you know which languages Marko knows? > A = macTruck > B = A > > In almost every other language you know A and B each "contain" by > reference (and almost always by static type) macTruck. But NOT python. Nor Javascript, Ruby, Perl, PHP, Lua, or (I think) Lisp or Java. To mention only a few. I think it is easy to exaggerate the difference between Python and "almost every other language". Python's name binding model is very common amongst dynamically typed languages, and there are many dynamically typed languages. If I have understood correctly, and I welcome confirmation or correction, one can have any combination of: * dynamic typing and name binding (e.g. Python and Ruby); * static typing and name binding (e.g. Java); * dynamic typing and fixed-location variables (any examples?); * static typing and fixed-location variables (C, Pascal). Where do VB and Perl fit into this? There are probably other variations as well. E.g. Cobra has both dynamic typed variables and static typed variables. > In almost every other language you know there is some kind of binding > table (name reference to type/length) and BOTH A and B are bound to data > in memory macTruck... and usually its a different place in memory! > > NOT python. Python has "binding tables" too. They are dicts. Any language with variables must have some way of mapping the name to the value. In some languages that mapping is available only to the compiler, and no longer exists at runtime (e.g. the assignment "x := 1;" is compiled to the equivalent of "copy value 1 into memory location 1234", with no reference to "x" remaining). In some languages the mapping is only available at runtime (e.g. the assignment "x := 1;" is compiled to the equivalent of "look up x and bind the value 1 to it"). In Python, lookups occur at runtime, not compile time. -- Steven D'Aprano http://import-that.dreamwidth.org/
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-05-08 12:09 +1000 |
| Message-ID | <mailman.9757.1399514964.18130.python-list@python.org> |
| In reply to | #71065 |
On Thu, May 8, 2014 at 11:27 AM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> If I have understood correctly, and I welcome confirmation or correction,
> one can have any combination of:
>
> * dynamic typing and name binding (e.g. Python and Ruby);
> * static typing and name binding (e.g. Java);
> * dynamic typing and fixed-location variables (any examples?);
> * static typing and fixed-location variables (C, Pascal).
Dynamic typing and fixed locations could really only be assembly
language, I think. It's all just bits in memory, and you treat them as
whatever you want. In C, signed and unsigned integers are different
types; in 80x86 assembly language, they're just integers, and you use
either JA or JG (Jump if Above vs Jump if Greater) to make unsigned or
signed comparisons. Or you can fetch a set of four bytes out of a byte
("character", ha) string and treat it as an integer - see for instance
the FOURCC system used in some audio files.
It's certainly not a normal way of writing code, but hey, it fills in
the hole in your set of four :)
ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve@pearwood.info> |
|---|---|
| Date | 2014-05-08 03:41 +0000 |
| Message-ID | <536afcf8$0$11109$c3e8da3@news.astraweb.com> |
| In reply to | #71070 |
On Thu, 08 May 2014 12:09:21 +1000, Chris Angelico wrote: > On Thu, May 8, 2014 at 11:27 AM, Steven D'Aprano > <steve+comp.lang.python@pearwood.info> wrote: >> If I have understood correctly, and I welcome confirmation or >> correction, one can have any combination of: >> >> * dynamic typing and name binding (e.g. Python and Ruby); * static >> typing and name binding (e.g. Java); * dynamic typing and >> fixed-location variables (any examples?); * static typing and >> fixed-location variables (C, Pascal). > > Dynamic typing and fixed locations could really only be assembly > language, I think. Not so! That's how __slots__ and local variables work in CPython. Objects are different sizes, so CPython can't allocate a box of a fixed size unless it knows how big the box needs to be. Fortunately, pointers are all the same size, so the object lives on the heap and the pointer goes in the box. The point being, there could be a language that used fixed locations for variables, while still being fully dynamically typed. That would allow the language to use pass-by-name or pass-by-reference semantics instead of pass-by-value or pass-by-shared-object. -- Steven
[toc] | [prev] | [next] | [standalone]
| From | Dan Sommers <dan@tombstonezero.net> |
|---|---|
| Date | 2014-05-08 03:43 +0000 |
| Message-ID | <lkeuhl$d1$1@dont-email.me> |
| In reply to | #71065 |
On Thu, 08 May 2014 01:27:08 +0000, Steven D'Aprano wrote: > If I have understood correctly, and I welcome confirmation or > correction, one can have any combination of: > * dynamic typing and name binding (e.g. Python and Ruby); > * static typing and name binding (e.g. Java); > * dynamic typing and fixed-location variables (any examples?); > * static typing and fixed-location variables (C, Pascal). C unions, if you squint just right, are fixed location variables and at least partially dynamic, within the bounds of what you define at compile time. And at the risk of opening another can of worms, C's typing is sufficiently weak that it can be way more dynamic than many programmers want. It's this |↔| close to assembly language (ChrisA's example of the combination of dynamic typing and fixed locations). Dan
[toc] | [prev] | [next] | [standalone]
| From | Mark H Harris <harrismh777@gmail.com> |
|---|---|
| Date | 2014-05-09 17:34 -0500 |
| Message-ID | <536D57E9.5080801@gmail.com> |
| In reply to | #71065 |
On 5/7/14 8:27 PM, Steven D'Aprano wrote:
>> In almost every other language you know A and B each "contain" by
>> reference (and almost always by static type) macTruck. But NOT python.
>
> Nor Javascript, Ruby, Perl, PHP, Lua, or (I think) Lisp or Java. To
> mention only a few.
>
> I think it is easy to exaggerate the difference between Python and
> "almost every other language". Python's name binding model is very common
> amongst dynamically typed languages, and there are many dynamically typed
> languages.
Then we don't need a discussion.
Why are new Python coders 'always' confused by this question of
variable (name value) vs. {name: object} model of Python?
The reason I suggest is that the person has a preconceived idea of
what 'variable' means, and they then attempt to apply their conception
of variable on to Python in some way ending in a surprise.
We need a way to speak about Pythons name object model to avoid
this confusion.
marcus
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2014-05-10 01:11 +0000 |
| Message-ID | <536d7cdf$0$29980$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #71199 |
On Fri, 09 May 2014 17:34:17 -0500, Mark H Harris wrote:
> On 5/7/14 8:27 PM, Steven D'Aprano wrote:
>>> In almost every other language you know A and B each "contain" by
>>> reference (and almost always by static type) macTruck. But NOT python.
>>
>> Nor Javascript, Ruby, Perl, PHP, Lua, or (I think) Lisp or Java. To
>> mention only a few.
>>
>> I think it is easy to exaggerate the difference between Python and
>> "almost every other language". Python's name binding model is very
>> common amongst dynamically typed languages, and there are many
>> dynamically typed languages.
>
> Then we don't need a discussion.
>
> Why are new Python coders 'always' confused by this question of
> variable (name value) vs. {name: object} model of Python?
"Always"? I don't think anyone, not even Ben, claims that new Python
coders are "always" confused about Python's variable semantics. That
would be a straw man, easy to disprove by just finding a single person
who wasn't confused. Perhaps someone who had never learned C and didn't
know C variable semantics?
> The reason I suggest is that the person has a preconceived idea of
> what 'variable' means, and they then attempt to apply their conception
> of variable on to Python in some way ending in a surprise.
That's the problem as some of us see it.
> We need a way to speak about Pythons name object model to avoid
> this confusion.
And that would be the "name binding" part.
--
Steven D'Aprano
http://import-that.dreamwidth.org/
[toc] | [prev] | [next] | [standalone]
| From | Larry Hudson <orgnut@yahoo.com> |
|---|---|
| Date | 2014-05-10 00:46 -0700 |
| Message-ID | <Btedne67vbL7RPDOnZ2dnUVZ_smdnZ2d@giganews.com> |
| In reply to | #71209 |
On 05/09/2014 06:11 PM, Steven D'Aprano wrote:
> On Fri, 09 May 2014 17:34:17 -0500, Mark H Harris wrote:
>
>> On 5/7/14 8:27 PM, Steven D'Aprano wrote:
<snip>
>> Why are new Python coders 'always' confused by this question of
>> variable (name value) vs. {name: object} model of Python?
>
> "Always"? I don't think anyone, not even Ben, claims that new Python
> coders are "always" confused about Python's variable semantics. That
> would be a straw man, easy to disprove by just finding a single person
> who wasn't confused. Perhaps someone who had never learned C and didn't
> know C variable semantics?
>
Well, here is that one person. ;-)
I'm an entirely self-taught amateur/hobbyist programmer, coming to Python from a C background.
Very early in my reading of books/tutorials on Python I learned that Python variables are
different, and how they are different from C variables. Essentially I said, "Okay, they're
different. What's next?" There was no confusion at all. All I had to do was accept that they
_are_ different. (BTW, I'm now quite hooked on Python -- and still learning it.)
>> The reason I suggest is that the person has a preconceived idea of
>> what 'variable' means, and they then attempt to apply their conception
>> of variable on to Python in some way ending in a surprise.
>
> That's the problem as some of us see it.
>
As I said above, not a problem. I already accepted the fact that all programming languages are
different -- often with similarities, but more often quite different, especially in the details.
So when programming in C I think in C-style variables, in Python I think in Python-style
variables. And uv course, I nefer make mmistakes... Yeah, right! ;-)
>
>> We need a way to speak about Pythons name object model to avoid
>> this confusion.
>
> And that would be the "name binding" part.
>
This is something I absolutely disagree with. I still think it's only necessary to teach that
variables in different languages are handled differently. Insisting on a different name is NOT
helpful. And insisting that Python does not have variables is ludicrous!
-=- Larry -=-
[toc] | [prev] | [next] | [standalone]
Page 1 of 8 [1] 2 3 4 5 6 7 8 Next page →
Back to top | Article view | comp.lang.python
csiph-web