On Mon, May 28, 2018 at 1:46 PM, Richard Damon wrote:
> On 5/25/18 6:28 PM, Steven D'Aprano wrote:
>> On Sat, 26 May 2018 02:58:06 +1000, Chris Angelico wrote:
>>
>>> Your mail/news client might choose to represent configure.ac as a link,
>>> since ".ac" is a valid TLD.
On 5/25/18 6:28 PM, Steven D'Aprano wrote:
> On Sat, 26 May 2018 02:58:06 +1000, Chris Angelico wrote:
>
>> Your mail/news client might choose to represent configure.ac as a link,
>> since ".ac" is a valid TLD.
> Isn't *everything* a valid TLD now?
>
> For the right price, at least.
>
Not quite,
If the behaviour of * on a sequence is confusing, then isn't the following
behaviour also confusing for exactly the same reason?
>>> a = [[]]
>>> b = a + a
>>> b
[[], []]
>>> b[0].append(5)
>>> b
[[5], [5]]
And if so, shouldn't there also be a concatenation operator that
On Fri, 25 May 2018 09:58:19 -0700, Rob Gaddi wrote:
> I agree that it's non-obvious, but I disagree with your diagnosis.
A further data point:
"I was not properly appreciating that that these
repeated objects were the *same identical* objects
that were in the pre-replicated
Steven D'Aprano wrote:
> On Fri, 25 May 2018 09:28:01 +0200, Peter Otten wrote:
>
>> Yet another arcanum to learn for beginners with little return. If you
>> cannot refrain from tinkering with the language at least concentrate on
>> the features with broad application. Thank you.
>
> Broader
bartc wrote:
/The/ matrix multiplication operator?
In which language? And what was wrong with "*"?
It seems you're unaware that Python *already* has an '@'
operator. It was added specifically so that numpy could
use it for matrix multiplication. A new operator was
needed because numpy already
Dennis Lee Bieber wrote:
@ requires use of the weaker/shorter "ring finger" on (for me) the
weaker left hand.
But... choosing an operator on that basis would be
discriminating against left-handed people!
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On Fri, 25 May 2018 09:58:19 -0700, Rob Gaddi wrote:
[...]
>> This is a frequent, recurring pain point. Experienced programmers
>> forget how confusing the behaviour of * is because they're so used to
>> the execution model. They forget that writing a list comp is not even
>> close to obvious,
On Fri, 25 May 2018 13:05:01 -0400, Dennis Lee Bieber wrote:
> Let me play devil's advocate... and propose a simple change, with
no
> new operators...
>
> sl = [] * n #current behavior
> dl = n * [] #deep copy behavior
n*[] is already supported. You will suddenly
On Sat, 26 May 2018 02:58:06 +1000, Chris Angelico wrote:
> Your mail/news client might choose to represent configure.ac as a link,
> since ".ac" is a valid TLD.
Isn't *everything* a valid TLD now?
For the right price, at least.
--
Steve
--
On 2018-05-25 18:05, Dennis Lee Bieber wrote:
On Fri, 25 May 2018 15:40:41 + (UTC), Steven D'Aprano
declaimed the following:
On Fri, 25 May 2018 22:46:37 +1000, Chris Angelico wrote:
We've already had a suggestion for [[]]@5 and that should deal
On 05/25/2018 10:13 AM, bartc wrote:
On 25/05/2018 17:58, Rob Gaddi wrote:
So, in the spirit of explicit being better than implicit, please
assume that for actual implementation replicate would be a static
method of actual list, rather than the conveniently executable hackjob
below.
_list
On 25/05/2018 17:58, Rob Gaddi wrote:
So, in the spirit of explicit being better than implicit, please assume
that for actual implementation replicate would be a static method of
actual list, rather than the conveniently executable hackjob below.
_list = list
_nodefault = object()
class
On 05/25/2018 04:53 AM, Steven D'Aprano wrote:
On Fri, 25 May 2018 09:28:01 +0200, Peter Otten wrote:
Yet another arcanum to learn for beginners with little return. If you
cannot refrain from tinkering with the language at least concentrate on
the features with broad application. Thank you.
On Sat, May 26, 2018 at 2:43 AM, bartc wrote:
> On 25/05/2018 17:11, Alexandre Brault wrote:
>>
>>
>>
>> On 2018-05-25 11:40 AM, bartc wrote:
>>>
>>> On 25/05/2018 16:27, Chris Angelico wrote:
You're way WAY too late to debate the matrix multiplication operator.
>>>
>>>
On Fri, 25 May 2018 17:12:12 +0100, bartc wrote:
> On 25/05/2018 16:40, Steven D'Aprano wrote:
[...]
>> On the other hand, it is arguable that what we really need is a
>> standard function to return an N-dimensional array/list:
>>
>> # return a 3x4x5x6 4-D list initialised to all zeroes arr =
>>
On 25/05/2018 17:11, Alexandre Brault wrote:
On 2018-05-25 11:40 AM, bartc wrote:
On 25/05/2018 16:27, Chris Angelico wrote:
You're way WAY too late to debate the matrix multiplication operator.
/The/ matrix multiplication operator?
In which language? And what was wrong with "*"?
In
On Fri, 25 May 2018 11:59:38 -0400, Dennis Lee Bieber wrote:
> What is your definition of a multi-dimensional array -- I tend to
think
> of them as pre-declared sizes; not the variable (row|column) lengths
> possible when using nested lists.
Any fixed size array can be implemented using
On 2018-05-25 11:40 AM, bartc wrote:
> On 25/05/2018 16:27, Chris Angelico wrote:
>> You're way WAY too late to debate the matrix multiplication operator.
>
> /The/ matrix multiplication operator?
>
> In which language? And what was wrong with "*"?
>
In Python, the language we're discussing
On 25/05/2018 16:40, Steven D'Aprano wrote:
On Fri, 25 May 2018 22:46:37 +1000, Chris Angelico wrote:
We've already had a suggestion for [[]]@5 and that should deal with that
issue. Steven is proposing "multiply by copying" as an alternative to
"multiply by referencing", so an alternative
On Sat, May 26, 2018 at 1:40 AM, bartc wrote:
> On 25/05/2018 16:27, Chris Angelico wrote:
>>
>> On Fri, May 25, 2018 at 10:58 PM, bartc wrote:
>>>
>>> I'm in general not in favour of piling in special symbols into a language
>>> just to solve some obscure or
On Sat, May 26, 2018 at 1:46 AM, Steven D'Aprano
wrote:
> On Fri, 25 May 2018 18:06:00 +1000, Chris Angelico wrote:
>
>> Downside: while it's all very well to say that this is equivalent to
>> copy.deepcopy(), that would imply replicating copy.deepcopy's
On Fri, 25 May 2018 18:06:00 +1000, Chris Angelico wrote:
> Downside: while it's all very well to say that this is equivalent to
> copy.deepcopy(), that would imply replicating copy.deepcopy's semantics
> in the core list type (unless it's actually literally defined as
> importing a module and
On Fri, 25 May 2018 18:06:00 +1000, Chris Angelico wrote:
> Downside: while it's all very well to say that this is equivalent to
> copy.deepcopy(), that would imply replicating copy.deepcopy's semantics
> in the core list type (unless it's actually literally defined as
> importing a module and
On 25/05/2018 16:27, Chris Angelico wrote:
On Fri, May 25, 2018 at 10:58 PM, bartc wrote:
I'm in general not in favour of piling in special symbols into a language
just to solve some obscure or rare problem.
As I went on to demonstrate, function-like syntax (or even actual
On Fri, 25 May 2018 22:46:37 +1000, Chris Angelico wrote:
> We've already had a suggestion for [[]]@5 and that should deal with that
> issue. Steven is proposing "multiply by copying" as an alternative to
> "multiply by referencing", so an alternative multiplication operator
> should fit that
On Fri, 25 May 2018 13:58:03 +0100, bartc wrote:
> As for '@', if a variable name can come before it /and/ after it, and
> either or both can be dotted, wouldn't that cause it to be highlighted
> as an email address in many circumstances? Such as in code posted here.
Sure.
And x/y might be
On Fri, May 25, 2018 at 10:58 PM, bartc wrote:
> I'm in general not in favour of piling in special symbols into a language
> just to solve some obscure or rare problem.
>
> As I went on to demonstrate, function-like syntax (or even actual functions)
> could do that job better, by
On 25/05/2018 13:46, Chris Angelico wrote:
On Fri, May 25, 2018 at 10:36 PM, bartc wrote:
On 24/05/2018 19:17, Steven D'Aprano wrote:
But what do people think about proposing a new list replication with copy
operator?
[[]]**5
would return a new list consisting of
On Fri, May 25, 2018 at 10:36 PM, bartc wrote:
> On 24/05/2018 19:17, Steven D'Aprano wrote:
>
>> But what do people think about proposing a new list replication with copy
>> operator?
>>
>> [[]]**5
>>
>> would return a new list consisting of five shallow copies of the inner
On 25/05/2018 13:36, bartc wrote:
Of course you have to implement dupllist(), but you'd have to implement
** too, and that is harder. For this specific example, it can just be:
def dupllist(x,n):
return [x[0].copy() for _ in range(n)]
On 25/05/2018 03:25, Steven D'Aprano wrote:
> You
On 24/05/2018 19:17, Steven D'Aprano wrote:
But what do people think about proposing a new list replication with copy
operator?
[[]]**5
would return a new list consisting of five shallow copies of the inner
list.
Thoughts?
Choice of ** doesn't seem right for a start, as it suggests it
On Fri, 25 May 2018 09:28:01 +0200, Peter Otten wrote:
> Yet another arcanum to learn for beginners with little return. If you
> cannot refrain from tinkering with the language at least concentrate on
> the features with broad application. Thank you.
Broader than multi-dimensional arrays? There
On Fri, 25 May 2018 11:48:49 +0100, Ben Bacarisse wrote:
> Another way of looking at it would be in terms of evaluation rather than
> copying. [] evaluates to a new list object, so if there were an
> alternate version of L * n (for the sake of argument L ** n) that
> evaluated the list
Steven D'Aprano writes:
> On Thu, 24 May 2018 16:05:32 -0700, Paul wrote:
>
>> How would one make a multi-dimensional list now, with truly-separate sub
>> lists? Is there just no way to do it with the replication operator?
>
> Correct. Let's say you want to
25.05.18 10:28, Peter Otten пише:
Steven D'Aprano wrote:
But what do people think about proposing a new list replication with copy
operator?
[[]]**5
would return a new list consisting of five shallow copies of the inner
list.
Yet another arcanum to learn for beginners with little
On Fri, May 25, 2018 at 5:50 PM, Stefan Behnel wrote:
> Peter Otten schrieb am 25.05.2018 um 09:28:
>> Steven D'Aprano wrote:
>>
>>> But what do people think about proposing a new list replication with copy
>>> operator?
>>>
>>> [[]]**5
>>>
>>> would return a new list
Peter Otten schrieb am 25.05.2018 um 09:28:
> Steven D'Aprano wrote:
>
>> But what do people think about proposing a new list replication with copy
>> operator?
>>
>> [[]]**5
>>
>> would return a new list consisting of five shallow copies of the inner
>> list.
>
> Yet another arcanum to
Steven D'Aprano wrote:
> But what do people think about proposing a new list replication with copy
> operator?
>
> [[]]**5
>
> would return a new list consisting of five shallow copies of the inner
> list.
Yet another arcanum to learn for beginners with little return.
If you cannot refrain
On Fri, 25 May 2018 02:45:38 +, Paul wrote:
> how often would people here have needed this new operator, if it had
> existed?
It is common enough that it is a FAQ on the Python website.
The list * operator isn't the most heavily used operator, but it does get
used a bit. It comes up quite
On Fri, 25 May 2018 15:30:36 +1000, Cameron Simpson wrote:
> So, how to various forms of multidimensional lists play out as code?
With my suggestion, we get:
x = [0]**3 # one-dimensional
y = [[0]**3]**3 # two-dimensional
z = [[[0]**3]**3]**3 # three-dimensional
Or there's MRAB's suggestion
On Fri, 25 May 2018 08:11:52 +0200, Stefan Behnel wrote:
> Steven D'Aprano schrieb am 25.05.2018 um 04:25:
[...]
>> You might be right: on further thought, I think I want deep copies, not
>> shallow.
>
> But how would that protocol work then? What would happen with a data
> structure like this:
Steven D'Aprano schrieb am 25.05.2018 um 04:25:
> On Thu, 24 May 2018 15:12:09 -0400, Ned Batchelder wrote:
>
>> On 5/24/18 2:17 PM, Steven D'Aprano wrote:
> [...]
>>> But what do people think about proposing a new list replication with
>>> copy operator?
>>>
>>> [[]]**5
>>>
>>> would return
On 25May2018 02:32, Steven D'Aprano
wrote:
On Fri, 25 May 2018 08:02:38 +1000, Cameron Simpson wrote:
I'm also against the "**" spelling I find, for much the same reasons
that people oppose allowing "=" and "==" in the same syntactic location:
they're
On 25May2018 02:25, Steven D'Aprano
wrote:
On Thu, 24 May 2018 15:12:09 -0400, Ned Batchelder wrote:
On 5/24/18 2:17 PM, Steven D'Aprano wrote:
[...]
But what do people think about proposing a new list replication with
copy operator?
[[]]**5
how often would people here have needed this new operator, if it had
existed?
--
https://mail.python.org/mailman/listinfo/python-list
On Thu, 24 May 2018 16:05:32 -0700, Paul wrote:
> How would one make a multi-dimensional list now, with truly-separate sub
> lists? Is there just no way to do it with the replication operator?
Correct. Let's say you want to make a 1-D list with three items
initialised to zero. This works
On Fri, 25 May 2018 08:02:38 +1000, Cameron Simpson wrote:
> I'm also against the "**" spelling I find, for much the same reasons
> that people oppose allowing "=" and "==" in the same syntactic location:
> they're easy to get wrong through typing inaccuracy.
Do you often write
y = 2**x
On Thu, 24 May 2018 15:12:09 -0400, Ned Batchelder wrote:
> On 5/24/18 2:17 PM, Steven D'Aprano wrote:
[...]
>> But what do people think about proposing a new list replication with
>> copy operator?
>>
>> [[]]**5
>>
>> would return a new list consisting of five shallow copies of the inner
>>
On Thu, 24 May 2018 11:24:41 -0700, Rob Gaddi wrote:
> On 05/24/2018 11:17 AM, Steven D'Aprano wrote:
[...]
>> But what do people think about proposing a new list replication with
>> copy operator?
>>
>> [[]]**5
>>
>> would return a new list consisting of five shallow copies of the inner
On 2018-05-25 00:05, Paul wrote:
How would one make a multi-dimensional list now, with truly-separate sub
lists? Is there just no way to do it with the replication operator? IE,
would I just have to do
X = [[], [], [], [], []]
or perhaps write a function to insert new sub lists into a list,
Paul writes:
> How would one make a multi-dimensional list now, with truly-separate sub
> lists? Is there just no way to do it with the replication operator? IE,
> would I just have to do
> X = [[], [], [], [], []]
The expressions in a comprehension are evaluated each
How would one make a multi-dimensional list now, with truly-separate sub
lists? Is there just no way to do it with the replication operator? IE,
would I just have to do
X = [[], [], [], [], []]
or perhaps write a function to insert new sub lists into a list, or...?
Thanks
> Paul C.
>
>
--
On 24May2018 18:17, Steven D'Aprano
wrote:
Python has a sequence replication operator:
py> [1, 2]*3
[1, 2, 1, 2, 1, 2]
Unfortunately, it is prone to a common "gotcha":
py> x = [[]]*5 # make a multi-dimensional list
py> x
[[], [], [], [], []]
py>
On 2018-05-24 20:12, Ned Batchelder wrote:
On 5/24/18 2:17 PM, Steven D'Aprano wrote:
Python has a sequence replication operator:
py> [1, 2]*3
[1, 2, 1, 2, 1, 2]
Unfortunately, it is prone to a common "gotcha":
py> x = [[]]*5 # make a multi-dimensional list
py> x
[[], [], [], [], []]
py>
On 5/24/18 2:17 PM, Steven D'Aprano wrote:
Python has a sequence replication operator:
py> [1, 2]*3
[1, 2, 1, 2, 1, 2]
Unfortunately, it is prone to a common "gotcha":
py> x = [[]]*5 # make a multi-dimensional list
py> x
[[], [], [], [], []]
py> x[0].append(1)
py> x
[[1], [1], [1], [1],
On 05/24/2018 11:17 AM, Steven D'Aprano wrote:
Python has a sequence replication operator:
py> [1, 2]*3
[1, 2, 1, 2, 1, 2]
Unfortunately, it is prone to a common "gotcha":
py> x = [[]]*5 # make a multi-dimensional list
py> x
[[], [], [], [], []]
py> x[0].append(1)
py> x
[[1], [1], [1], [1],
Python has a sequence replication operator:
py> [1, 2]*3
[1, 2, 1, 2, 1, 2]
Unfortunately, it is prone to a common "gotcha":
py> x = [[]]*5 # make a multi-dimensional list
py> x
[[], [], [], [], []]
py> x[0].append(1)
py> x
[[1], [1], [1], [1], [1]]
The reason for this behaviour is that *
58 matches
Mail list logo