Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #99091 > unrolled thread
| Started by | Laura Creighton <lac@openend.se> |
|---|---|
| First post | 2015-11-19 21:18 +0100 |
| Last post | 2015-11-25 10:13 +0100 |
| Articles | 6 on this page of 86 — 17 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: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Laura Creighton <lac@openend.se> - 2015-11-19 21:18 +0100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Marko Rauhamaa <marko@pacujo.net> - 2015-11-19 22:57 +0200
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Laura Creighton <lac@openend.se> - 2015-11-19 23:41 +0100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) BartC <bc@freeuk.com> - 2015-11-20 14:00 +0000
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Steven D'Aprano <steve@pearwood.info> - 2015-11-20 11:33 +1100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-25 09:14 +0100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Steven D'Aprano <steve@pearwood.info> - 2015-11-25 21:52 +1100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-25 13:25 +0100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) BartC <bc@freeuk.com> - 2015-11-25 13:20 +0000
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Ned Batchelder <ned@nedbatchelder.com> - 2015-11-25 07:13 -0800
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Laura Creighton <lac@openend.se> - 2015-11-25 16:59 +0100
Multiplication [was Re: Late-binding of function defaults] Steven D'Aprano <steve@pearwood.info> - 2015-11-26 05:09 +1100
Re: Multiplication [was Re: Late-binding of function defaults] Laura Creighton <lac@openend.se> - 2015-11-25 19:45 +0100
Re: Multiplication [was Re: Late-binding of function defaults] Marko Rauhamaa <marko@pacujo.net> - 2015-11-25 23:04 +0200
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Arie van Wingerden <xapwing@gmail.com> - 2015-11-25 17:12 +0100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Chris Angelico <rosuav@gmail.com> - 2015-11-26 03:29 +1100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) BartC <bc@freeuk.com> - 2015-11-25 17:18 +0000
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-25 11:03 -0700
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) BartC <bc@freeuk.com> - 2015-11-25 18:48 +0000
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-11-25 20:50 +0000
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) BartC <bc@freeuk.com> - 2015-11-25 21:56 +0000
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Marko Rauhamaa <marko@pacujo.net> - 2015-11-26 00:16 +0200
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) BartC <bc@freeuk.com> - 2015-11-25 22:41 +0000
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Steven D'Aprano <steve@pearwood.info> - 2015-11-26 11:31 +1100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) BartC <bc@freeuk.com> - 2015-11-26 01:23 +0000
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Ned Batchelder <ned@nedbatchelder.com> - 2015-11-25 17:52 -0800
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Ben Finney <ben+python@benfinney.id.au> - 2015-11-26 16:08 +1100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-11-26 06:39 +0000
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-26 09:31 +0100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) BartC <bc@freeuk.com> - 2015-11-26 12:53 +0000
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Chris Angelico <rosuav@gmail.com> - 2015-11-27 00:15 +1100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) BartC <bc@freeuk.com> - 2015-11-26 14:40 +0000
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) MRAB <python@mrabarnett.plus.com> - 2015-11-26 16:14 +0000
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) BartC <bc@freeuk.com> - 2015-11-26 22:27 +0000
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Chris Angelico <rosuav@gmail.com> - 2015-11-27 10:07 +1100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Random832 <random832@fastmail.com> - 2015-11-26 19:15 -0500
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Chris Angelico <rosuav@gmail.com> - 2015-11-27 11:48 +1100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) MRAB <python@mrabarnett.plus.com> - 2015-11-27 01:15 +0000
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) MRAB <python@mrabarnett.plus.com> - 2015-11-26 16:16 +0000
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-11-27 10:48 +1300
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Steven D'Aprano <steve@pearwood.info> - 2015-11-27 12:46 +1100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) BartC <bc@freeuk.com> - 2015-11-27 02:01 +0000
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Marko Rauhamaa <marko@pacujo.net> - 2015-11-26 08:41 +0200
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Steven D'Aprano <steve@pearwood.info> - 2015-11-27 12:09 +1100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) BartC <bc@freeuk.com> - 2015-11-27 10:31 +0000
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Marko Rauhamaa <marko@pacujo.net> - 2015-11-27 13:30 +0200
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Ben Finney <ben+python@benfinney.id.au> - 2015-11-26 06:57 +1100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Marko Rauhamaa <marko@pacujo.net> - 2015-11-25 23:00 +0200
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Emile van Sebille <emile@fenx.com> - 2015-11-25 10:56 -0800
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Steven D'Aprano <steve@pearwood.info> - 2015-11-26 13:01 +1100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Chris Angelico <rosuav@gmail.com> - 2015-11-26 00:24 +1100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-25 15:17 +0100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Emile van Sebille <emile@fenx.com> - 2015-11-25 10:51 -0800
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Chris Angelico <rosuav@gmail.com> - 2015-11-25 19:32 +1100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Marko Rauhamaa <marko@pacujo.net> - 2015-11-25 10:43 +0200
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Steven D'Aprano <steve@pearwood.info> - 2015-11-25 21:58 +1100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) BartC <bc@freeuk.com> - 2015-11-25 12:35 +0000
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Marko Rauhamaa <marko@pacujo.net> - 2015-11-25 15:06 +0200
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) BartC <bc@freeuk.com> - 2015-11-25 13:37 +0000
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Marko Rauhamaa <marko@pacujo.net> - 2015-11-25 15:53 +0200
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) BartC <bc@freeuk.com> - 2015-11-25 14:34 +0000
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-11-25 13:32 -0500
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Steven D'Aprano <steve@pearwood.info> - 2015-11-26 11:53 +1100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Marko Rauhamaa <marko@pacujo.net> - 2015-11-26 08:52 +0200
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Chris Angelico <rosuav@gmail.com> - 2015-11-26 18:14 +1100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Marko Rauhamaa <marko@pacujo.net> - 2015-11-26 10:27 +0200
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Chris Angelico <rosuav@gmail.com> - 2015-11-26 19:34 +1100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Marko Rauhamaa <marko@pacujo.net> - 2015-11-26 12:54 +0200
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Chris Angelico <rosuav@gmail.com> - 2015-11-26 22:04 +1100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Marko Rauhamaa <marko@pacujo.net> - 2015-11-26 13:23 +0200
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Chris Angelico <rosuav@gmail.com> - 2015-11-26 22:35 +1100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Marko Rauhamaa <marko@pacujo.net> - 2015-11-26 14:03 +0200
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Steven D'Aprano <steve@pearwood.info> - 2015-11-27 12:43 +1100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-26 09:45 +0100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-11-27 10:20 +1300
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Marko Rauhamaa <marko@pacujo.net> - 2015-11-26 23:36 +0200
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Steven D'Aprano <steve@pearwood.info> - 2015-11-27 12:23 +1100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-11-26 11:17 +0000
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Chris Angelico <rosuav@gmail.com> - 2015-11-26 00:44 +1100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Ben Finney <ben+python@benfinney.id.au> - 2015-11-26 06:55 +1100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Random832 <random832@fastmail.com> - 2015-11-26 00:52 +0000
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-25 20:01 -0700
Semantics of collection types (was: Late-binding of function defaults (was Re: What is a function parameter =[] for?)) Ben Finney <ben+python@benfinney.id.au> - 2015-11-26 16:04 +1100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Chris Angelico <rosuav@gmail.com> - 2015-11-26 00:35 +1100
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Larry Hudson <orgnut@yahoo.com> - 2015-11-25 22:44 -0800
Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-25 10:13 +0100
Page 5 of 5 — ← Prev page 1 2 3 4 [5]
| From | Random832 <random832@fastmail.com> |
|---|---|
| Date | 2015-11-26 00:52 +0000 |
| Message-ID | <mailman.107.1448499195.20593.python-list@python.org> |
| In reply to | #99445 |
On 2015-11-25, Ben Finney <ben+python@benfinney.id.au> wrote: > That is, the ‘2’ in ‘cartesian_point = (2, 3)’ means something different > than in ‘cartesian_point = (3, 2)’. > > Whereas the ‘2’ in ‘test_scores = [2, 3]’ means exactly the same as in > ‘test_scores = [3, 2]’. > > If each position in the sequence gives the value there a different > menaning, use a tuple; if not, use a list. I don't think that's really right. The absence of first-class multisets in python does mean that lists get "abused" for that purpose, but I don't think that means that there's no legitimate use-case for a list (i.e. a mutable sequence in which position is significant). The difference between a tuple and a list is that one is mutable and the other is not. The difference you are describing is between a list and a multiset (or a tuple and an immutable multiset).
[toc] | [prev] | [next] | [standalone]
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2015-11-25 20:01 -0700 |
| Message-ID | <mailman.112.1448507345.20593.python-list@python.org> |
| In reply to | #99445 |
On Wed, Nov 25, 2015 at 5:52 PM, Random832 <random832@fastmail.com> wrote: > On 2015-11-25, Ben Finney <ben+python@benfinney.id.au> wrote: >> That is, the ‘2’ in ‘cartesian_point = (2, 3)’ means something different >> than in ‘cartesian_point = (3, 2)’. >> >> Whereas the ‘2’ in ‘test_scores = [2, 3]’ means exactly the same as in >> ‘test_scores = [3, 2]’. >> >> If each position in the sequence gives the value there a different >> menaning, use a tuple; if not, use a list. > > I don't think that's really right. The absence of first-class > multisets in python does mean that lists get "abused" for that > purpose, but I don't think that means that there's no legitimate > use-case for a list (i.e. a mutable sequence in which position is > significant). > > The difference between a tuple and a list is that one is mutable > and the other is not. The difference you are describing is > between a list and a multiset (or a tuple and an immutable > multiset). I think that Ben was actually trying to make a distinction between heterogeneity and homogeneity of the contents, not a distinction of whether the collection was ordered or not. You can of course have a homogeneous collection for which order is still important, e.g. a batting line-up.
[toc] | [prev] | [next] | [standalone]
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Date | 2015-11-26 16:04 +1100 |
| Subject | Semantics of collection types (was: Late-binding of function defaults (was Re: What is a function parameter =[] for?)) |
| Message-ID | <mailman.113.1448514292.20593.python-list@python.org> |
| In reply to | #99445 |
Ian Kelly <ian.g.kelly@gmail.com> writes: > On Wed, Nov 25, 2015 at 5:52 PM, Random832 <random832@fastmail.com> wrote: > > On 2015-11-25, Ben Finney <ben+python@benfinney.id.au> wrote: > >> That is, the ‘2’ in ‘cartesian_point = (2, 3)’ means something > >> different than in ‘cartesian_point = (3, 2)’. > >> > >> Whereas the ‘2’ in ‘test_scores = [2, 3]’ means exactly the same as > >> in ‘test_scores = [3, 2]’. > >> > >> If each position in the sequence gives the value there a different > >> menaning, use a tuple; if not, use a list. > > > > I don't think that's really right. I was expanding on (by replying to) earlier advice about expressing semantics in our choice of data types. > > The difference between a tuple and a list is that one is mutable > > and the other is not. That is a difference enforced in the behaviour of the types, yes. I didn't talk about behaviour, but about meaning. I'm saying that the behavioural difference conveniently lines up with a semantic difference, even to the point of the meaning of “tuple” that pre-dates Python. > I think that Ben was actually trying to make a distinction between > heterogeneity and homogeneity of the contents, not a distinction of > whether the collection was ordered or not. That's right, thank you. -- \ “Nothing exists except atoms and empty space; everything else | `\ is opinion.” —Democritus, c. 460 BCE – 370 BCE | _o__) | Ben Finney
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2015-11-26 00:35 +1100 |
| Message-ID | <mailman.70.1448458541.20593.python-list@python.org> |
| In reply to | #99442 |
On Wed, Nov 25, 2015 at 11:35 PM, BartC <bc@freeuk.com> wrote:
> One gotcha at least is well known. Where, in a language of the least
> surprises, you might write:
>
> d1 = date (25,12,2010)
> d2 = d1
> d2.year += 1
>
> You would expect d1 and d2 to represent a period one year apart. In Python,
> they would both be the later date.
I'm not sure why this is "a language of least surprises". It's just a
language of *different* surprises. I'll give you an example of exactly
that: PHP has semantics similar to what you're describing.
$ php
<?php
$a = array("foo", "bar");
$b = $a;
$b[1] = "baz";
print_r($a);
^D
Array
(
[0] => foo
[1] => bar
)
I'm not exactly sure of the definition of PHP's assignment, as it's
been a while since I looked it up; but it seems to be something like
what you're describing. This seems well and good, until you start
contemplating gigantic arrays and what happens when you pass them from
one function to another. What're your performance expectations? With
Python, I know that "a = b" happens in constant time, and I also know
that the performance of "a[1]=2" is not going to be affected by any
other names that might be bound to the same object. PHP's references
make this even more messy:
$ php
<?php
$a = array("foo", "bar");
$b = &$a[1];
$b = $a;
$b[1] = "baz";
print_r($a);
^D
Array
(
[0] => foo
[1] => baz
)
So... since I'd previously set $b to be a reference, now assigning to
it does something different. And what, exactly? Is $a[1] the exact
same array as $a? Has any copying happened? When I change $b[1], is
that the same as changing $a[1], or is it actually changing $a[1][1],
and is that even any different?
This isn't a magical solution to all surprises, except perhaps in that
you've built a language yourself, so it conforms perfectly to *your*
expectations. You can never make something that fits everyone's
expectations, so you'll always have surprises somewhere. It's just a
question of where, and how easily they can be explained when someone
runs into them.
ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Larry Hudson <orgnut@yahoo.com> |
|---|---|
| Date | 2015-11-25 22:44 -0800 |
| Message-ID | <DdSdnUfq3sfHN8vLnZ2dnUU7-XudnZ2d@giganews.com> |
| In reply to | #99421 |
On 11/25/2015 12:32 AM, Chris Angelico wrote:
> On Wed, Nov 25, 2015 at 7:14 PM, Antoon Pardon
> <antoon.pardon@rece.vub.ac.be> wrote:
>> [snip]
>
> "Oh come on. It's basic arithmetic. You should be able to add 7 and
> 7... the result's 14!"
>
> "But it's so confusing. Why can't it be 16? It'd be more convenient
> for me if it were 16."
No. It's 42. ;-)
-=- Larry -=-
<The Hitchhiker's Guide to the Galaxy says that's what *The Answer* is.>
[toc] | [prev] | [next] | [standalone]
| From | Antoon Pardon <antoon.pardon@rece.vub.ac.be> |
|---|---|
| Date | 2015-11-25 10:13 +0100 |
| Message-ID | <mailman.60.1448442811.20593.python-list@python.org> |
| In reply to | #99114 |
Op 25-11-15 om 09:32 schreef Chris Angelico: > On Wed, Nov 25, 2015 at 7:14 PM, Antoon Pardon > <antoon.pardon@rece.vub.ac.be> wrote: >> What exactly is your point? People's confusions don't disappear >> because you as an expert have a good understanding of what is >> going on and so are no longer confused. >> >> Some aspects in the langauage are easily grasped and other >> aspects tend to create confusion. I see nothing wrong with >> people trying to point out what the cause of this confusion >> could be. You arguing that people shouldn't be confused is >> not helping. > "Oh come on. It's basic arithmetic. You should be able to add 7 and > 7... the result's 14!" > > "But it's so confusing. Why can't it be 16? It'd be more convenient > for me if it were 16." > > "This is just how arithmetic works." > > "But it's still confusing!" > > At some point, you have to simply accept that this is how the system > works.. or use a different system. (Octal maybe.) If you are > perpetually confused by Python, you need to either learn how Python > works, or use something else. Those are not the only choices. The third option is that those at the drawing board of python come to the conclusion that some aspect of python is needlessly confusing and change the design. I also find your comparison disingenous. The responses I see often enough are not simply: this is how python works. They are often enough something like: How can you find this confusing, you shouldn't. If the regulars would answer more something like: Yes it can be confusing, you are not the only one, but let me explain what is going on. and the other would keep complaining about it being confusing, you would have a point. Instead the regulars all too often go on a tangent on how it shouldn't be confusing or something similar and then they are surprised that the exchange that follows isn't very fruitful. -- Antoon Pardon
[toc] | [prev] | [standalone]
Page 5 of 5 — ← Prev page 1 2 3 4 [5]
Back to top | Article view | comp.lang.python
csiph-web