In article 4ca6bd15$0$2$c3e8...@news.astraweb.com,
Steven D'Aprano st...@remove-this-cybersource.com.au wrote:
On Fri, 01 Oct 2010 14:56:52 +0200, Antoon Pardon wrote:
Think about the following possibility.
Someone provides you with a library of functions that act on sequences.
They rely
On Sat, Oct 02, 2010 at 04:38:16AM +, Steven D'Aprano wrote:
On Fri, 01 Oct 2010 10:24:11 -0700, Carl Banks wrote:
On Sep 26, 8:20 am, Grant Edwards inva...@invalid.invalid wrote:
[..]
So now I suppose + for string concatenation is a bad thing.
Yes. It's not the end of the world,
On Fri, Oct 01, 2010 at 09:44:34AM -0700, Emile van Sebille wrote:
On 10/1/2010 5:56 AM Antoon Pardon said...
Someone provides you with a library of functions that act on sequences.
They rely on the fact that '+' concatenates.
Someone else provides you with a library of functions that act
On Sat, Oct 02, 2010 at 05:03:17AM +, Steven D'Aprano wrote:
On Fri, 01 Oct 2010 14:56:52 +0200, Antoon Pardon wrote:
Think about the following possibility.
Someone provides you with a library of functions that act on sequences.
They rely on the fact that '+' concatenates.
Antoon Pardon wrote:
Suppose you write your class so that '+' will provide addition and
you provide a method concat to concatenate. Now no matter how usefull
the sequence library would be for you, you can't use it. You will
have to rewrite those function you need, in terms of a concat method
On 10/2/2010 8:36 AM, Carl Banks wrote:
On Oct 1, 9:38 pm, Steven D'Apranost...@remove-this-
cybersource.com.au wrote:
If so, then we haven't gained anything, and the only thing that would
satisfy such people would be for every function name and operator to be
unique -- something which is
On Oct 4, 9:14 am, Ethan Furman et...@stoneleaf.us wrote:
Antoon Pardon wrote:
Suppose you write your class so that '+' will provide addition and
you provide a method concat to concatenate. Now no matter how usefull
the sequence library would be for you, you can't use it. You will
have to
Carl Banks wrote:
Numpy uses + for elementwise addition, and a function
called concatenate for concatenation. If Python lists used a separate
concatenation operator, then Numpy arrays could use that for
concatenation.
Actually it couldn't, except for the special case of
concatenating along
On Oct 4, 3:09 pm, Gregory Ewing greg.ew...@canterbury.ac.nz wrote:
Carl Banks wrote:
Numpy uses + for elementwise addition, and a function
called concatenate for concatenation. If Python lists used a separate
concatenation operator, then Numpy arrays could use that for
concatenation.
Seebs wrote:
On 2010-10-03, Steven D'Aprano st...@remove-this-cybersource.com.au
wrote:
On Sat, 02 Oct 2010 12:50:02 -0700, Dennis Lee Bieber wrote:
Well... We could maybe borrow from REXX... and
use || for concatenation.
|| for concatenation? What's the connection between the
Stefan Schwarzer a écrit :
One could argue that using L[::-1] isn't obvious
It *is* obvious - once you've learned slicing. obvious doesn't mean
you shouldn't bother reading the FineManual.
--
http://mail.python.org/mailman/listinfo/python-list
On Oct 1, 9:38 pm, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:
If so, then we haven't gained anything, and the only thing that would
satisfy such people would be for every function name and operator to be
unique -- something which is impossible in practice, even if it were
On 02/10/2010 20:50, Dennis Lee Bieber wrote:
On 02 Oct 2010 04:38:16 GMT, Steven D'Aprano
st...@remove-this-cybersource.com.au declaimed the following in
gmane.comp.python.general:
If so, then we haven't gained anything, and the only thing that would
satisfy such people would be for every
On Sat, Oct 2, 2010 at 1:24 PM, MRAB pyt...@mrabarnett.plus.com wrote:
On 02/10/2010 20:50, Dennis Lee Bieber wrote:
On 02 Oct 2010 04:38:16 GMT, Steven D'Aprano
st...@remove-this-cybersource.com.au declaimed the following in
gmane.comp.python.general:
If so, then we haven't gained
On 02/10/2010 22:12, Dennis Lee Bieber wrote:
On Sat, 02 Oct 2010 21:24:19 +0100, MRABpyt...@mrabarnett.plus.com
declaimed the following in gmane.comp.python.general:
How about ~, which is currently has only a unary form:
foo ~ bar
'foobar'
[1, 2, 3] ~ [4, 5, 6]
[1, 2, 3, 4, 5, 6]
On Sat, 02 Oct 2010 14:12:39 -0700, Dennis Lee Bieber wrote:
I'd prefer to see it used for floating point comparison in the two
character:
x ~= y
though one might need to set up some system parameter to define what the
permissible delta would be...
On Sat, 02 Oct 2010 14:09:15 -0700, geremy condra wrote:
I'd actually love the ability to overload this, although I'm not sold on
the itertools.chain thing. To me it looks a lot like the 'is isomorphic'
operator from graph theory, and we could really use that in Graphine.
You can overload the
On Sat, 02 Oct 2010 12:50:02 -0700, Dennis Lee Bieber wrote:
Well... We could maybe borrow from REXX... and
use || for concatenation.
|| for concatenation? What's the connection between the pipe character
and concatenation? I realise that, ultimately, every symbol was
On 2010-10-03, Steven D'Aprano st...@remove-this-cybersource.com.au wrote:
On Sat, 02 Oct 2010 12:50:02 -0700, Dennis Lee Bieber wrote:
Well... We could maybe borrow from REXX... and
use || for concatenation.
|| for concatenation? What's the connection between the pipe
On Thu, Sep 30, 2010 at 07:02:40AM -0700, Emile van Sebille wrote:
On 9/30/2010 5:10 AM Antoon Pardon said...
On Sun, Sep 26, 2010 at 03:20:18PM +, Grant Edwards wrote:
On 2010-09-26, Paul Rubinno.em...@nospam.invalid wrote:
Steven D'Apranost...@remove-this-cybersource.com.au writes:
On 10/1/2010 5:56 AM Antoon Pardon said...
Someone provides you with a library of functions that act on sequences.
They rely on the fact that '+' concatenates.
Someone else provides you with a library of functions that act on
numbers. They rely on the fact that '+' provides addition.
But
On 10/1/2010 9:44 AM Emile van Sebille said...
On 10/1/2010 5:56 AM Antoon Pardon said...
Someone provides you with a library of functions that act on sequences.
They rely on the fact that '+' concatenates.
Someone else provides you with a library of functions that act on
numbers. They rely
On Sep 26, 8:20 am, Grant Edwards inva...@invalid.invalid wrote:
On 2010-09-26, Paul Rubin no.em...@nospam.invalid wrote:
Steven D'Aprano st...@remove-this-cybersource.com.au writes:
There's nothing obscure or unintuitive about spam*3 = spamspamspam,
Why would it not be [spam,spam,spam] or
On Fri, 01 Oct 2010 10:24:11 -0700, Carl Banks wrote:
On Sep 26, 8:20 am, Grant Edwards inva...@invalid.invalid wrote:
[..]
So now I suppose + for string concatenation is a bad thing.
Yes. It's not the end of the world, but a separate concatenation
operator would have been better. Then
On Fri, 01 Oct 2010 14:56:52 +0200, Antoon Pardon wrote:
Think about the following possibility.
Someone provides you with a library of functions that act on sequences.
They rely on the fact that '+' concatenates.
Someone else provides you with a library of functions that act on
numbers.
On Sun, Sep 26, 2010 at 03:20:18PM +, Grant Edwards wrote:
On 2010-09-26, Paul Rubin no.em...@nospam.invalid wrote:
Steven D'Aprano st...@remove-this-cybersource.com.au writes:
There's nothing obscure or unintuitive about spam*3 = spamspamspam,
Why would it not be [spam,spam,spam] or
On 9/30/2010 5:10 AM Antoon Pardon said...
On Sun, Sep 26, 2010 at 03:20:18PM +, Grant Edwards wrote:
On 2010-09-26, Paul Rubinno.em...@nospam.invalid wrote:
Steven D'Apranost...@remove-this-cybersource.com.au writes:
There's nothing obscure or unintuitive about spam*3 = spamspamspam,
In message slrni9u4kv.28r0.usenet-nos...@guild.seebs.net, Seebs wrote:
Helps, perhaps, that I got exposed to group theory early enough to be used
to redefining + and * to be any two operations which have interesting
properties ...
But groups only have one such operation; it’s rings and fields
On 2010-09-29, Lawrence D'Oliveiro l...@geek-central.gen.new_zealand wrote:
In message slrni9u4kv.28r0.usenet-nos...@guild.seebs.net, Seebs wrote:
Helps, perhaps, that I got exposed to group theory early enough to be used
to redefining + and * to be any two operations which have interesting
On Sat, 25 Sep 2010 22:08:54 -0700, John Nagle wrote:
On 9/25/2010 4:45 AM, Thomas Jollans wrote:
On Saturday 25 September 2010, it occurred to Yingjie Lan to exclaim:
Hi,
I noticed that in python3k, multiplying a sequence by a negative
integer is the same as multiplying it by 0, and the
Steven D'Aprano st...@remove-this-cybersource.com.au writes:
I'm surprised that you think that you should be able to apply
arbitrary mathematical operations to strings *before* turning them
into an int and still get sensible results. That boggles my mind.
I think the idea is you should not be
On Sat, 25 Sep 2010 23:46:57 -0700, Paul Rubin wrote:
Steven D'Aprano st...@remove-this-cybersource.com.au writes:
I'm surprised that you think that you should be able to apply arbitrary
mathematical operations to strings *before* turning them into an int
and still get sensible results. That
Steven D'Aprano st...@remove-this-cybersource.com.au writes:
There's nothing obscure or unintuitive about spam*3 = spamspamspam,
Why would it not be [spam,spam,spam] or even ssspppaaammm?
Should spam*2.5 be spamspamsp?
Should spam-a be spm? What about spamspam-a?
And what about spam/2? sp be
On 2010-09-26, Steven D'Aprano st...@remove-this-cybersource.com.au wrote:
On Sat, 25 Sep 2010 23:46:57 -0700, Paul Rubin wrote:
I think the idea is you should not be able to do mathematical operations
on strings, and if you try to do one, Python should raise an exception,
rather than using
Seebs usenet-nos...@seebs.net writes:
* It seems clear that, given two sequences x and y, x + y ought to
be the concatenation of these sequences.
...
Helps, perhaps, that I got exposed to group theory early enough to be used
to redefining + and * to be any two operations which have
On 26/09/2010 07:27, Steven D'Aprano wrote:
I'm surprised that you think that you
should be able to apply arbitrary mathematical operations to strings
*before* turning them into an int and still get sensible results. That
boggles my mind.
You clearly have not been spoiled rotten by php.
that there is a more meaningful symantics.
Simply put, a sequence multiplied by -1 can give a reversed sequence.
Then for any sequence seq, and integer n0, we can have
seq * -n producing (seq * -1) * n.
Any thoughts?
Gimmicky.
Best to define multiplication only by unsigned or positive values.
--
Bartc
On 2010-09-26, Paul Rubin no.em...@nospam.invalid wrote:
Steven D'Aprano st...@remove-this-cybersource.com.au writes:
There's nothing obscure or unintuitive about spam*3 = spamspamspam,
Why would it not be [spam,spam,spam] or even ssspppaaammm?
Because
3 * spam == spam + spam + spam
Just
Grant Edwards wrote:
On 2010-09-26, Paul Rubin no.em...@nospam.invalid wrote:
Steven D'Aprano st...@remove-this-cybersource.com.au writes:
There's nothing obscure or unintuitive about spam*3 = spamspamspam,
Why would it not be [spam,spam,spam] or even ssspppaaammm?
Because
3 * spam ==
On 9/26/2010 1:16 AM, Paul Rubin wrote:
Steven D'Apranost...@remove-this-cybersource.com.au writes:
There's nothing obscure or unintuitive about spam*3 = spamspamspam,
Why would it not be [spam,spam,spam] or even ssspppaaammm?
Should spam*2.5 be spamspamsp?
Should spam-a be spm? What about
Paul Rubin no.em...@nospam.invalid writes:
Seebs usenet-nos...@seebs.net writes:
* It seems clear that, given two sequences x and y, x + y ought to
be the concatenation of these sequences.
...
Helps, perhaps, that I got exposed to group theory early enough to be used
to redefining + and *
On Sun, 26 Sep 2010 01:16:49 -0700, Paul Rubin wrote:
Steven D'Aprano st...@remove-this-cybersource.com.au writes:
There's nothing obscure or unintuitive about spam*3 = spamspamspam,
Why would it not be [spam,spam,spam] or even ssspppaaammm?
The first one would be a reasonable design choice,
On Sun, 26 Sep 2010 09:30:08 +, Seebs wrote:
There's nothing obscure or unintuitive about spam*3 = spamspamspam,
and the fact that it doesn't do the same thing as int(spam)*3 is a
foolish argument.
The languages in which it's surprising are mostly things like perl,
where there's a
Hi,
I noticed that in python3k, multiplying a sequence by a negative integer is the
same as multiplying it by 0, and the result is an empty sequence. It seems to
me that there is a more meaningful symantics.
Simply put, a sequence multiplied by -1 can give a reversed sequence.
Then for any
for the operation to succeed for any integer operand.
Simply put, a sequence multiplied by -1 can give a reversed sequence.
For that, we have slicing. A negative step value produces a reverse slice of
the list. You can't argue that this makes sense, can you
[1,2,3,4][::-1]
[4, 3, 2, 1]
[1,2,3,4][::-2]
[4
:
len(l*n) == len(l) * abs(n),
which is also broken under current python3k.
if you think len(..) as a mathematical norm,
the above invariance makes perfect sense:
|| a * b || == ||a|| * |b|, b is real
Simply put, a sequence multiplied by -1 can give a
reversed sequence.
For that, we
Hi,
On 2010-09-25 14:11, Yingjie Lan wrote:
Having more than one way of doing things sometimes is good.
In my opinion this _isn't_ a situation where it's good. :)
L[::-1]
is only marginally longer than
-1 * L
I think this small gain doesn't justify violating this
Python Zen rule
Hi,
In my opinion this _isn't_ a situation where it's good. :)
L[::-1]
is only marginally longer than
-1 * L
I think this small gain doesn't justify violating this
Python Zen rule (from `import this`):
There should be one-- and preferably only one
--obvious way to
Hi,
On 2010-09-25 15:54, Yingjie Lan wrote:
The first one is simpler (4 chars v.s. 9 chars).
One thing is whether a certain form is shorter, another
thing to take into account is how often you need the
functionality.
I thought it was also intuitive because if you multiply
a vector by -1, you
Stefan Schwarzer wrote:
On 2010-09-25 15:54, Yingjie Lan wrote:
The first one is simpler (4 chars v.s. 9 chars).
I thought it was also intuitive because if you multiply
a vector by -1, you should get a vector
in the reversed direction. But, intuitiveness depends
on who you are, what you do,
sequence of the same type as s).) I would have
made this raise a ValueError, but someone must have had a use case for
getting an empty sequence.
It seems to me that there is a more meaningful symantics.
Simply put, a sequence multiplied by -1 can give a reversed
sequence.
There is already a builtin
On 9/25/2010 10:24 AM Terry Reedy said...
On 9/25/2010 4:22 AM, Yingjie Lan wrote:
I noticed that in python3k, multiplying a sequence by a negative
integer is the same as multiplying it by 0, and the result is an
empty sequence.
This is explicitly documented: Values of n less than 0 are
Hi Terry,
On 2010-09-25 19:24, Terry Reedy wrote:
On 9/25/2010 4:22 AM, Yingjie Lan wrote:
There is already a builtin reversed() function whose output can be
multiplied.
Seemingly, it can't:
$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type help,
multiplied by -1 can give a reversed sequence.
Then for any sequence seq, and integer n0, we can have
seq * -n producing (seq * -1) * n.
Any thoughts?
Yingjie
If [1, 2]*-1 is correct, then, arguably, so should be -[1, 2] :)
Some answers have invoked mathematics to weigh the value
which has a less restrictive domain and is more
useful than raising an exception:
for every list l and integer n:
len(l*n) == len(l)*max(0, n)
Simply put, a sequence multiplied by -1 can give a reversed sequence.
For that, we have slicing. A negative step value produces a reverse
slice
On Sat, 25 Sep 2010 06:54:36 -0700, Yingjie Lan wrote:
For the rule above, how about the
case to reverse and multiply:
L*-3 #L reversed and repeated three times
v.s.
L[::-1]*3 #L reversed and repeated three times
The first one is simpler (4 chars v.s. 9 chars). I thought it was also
Hi all,
Thanks for considering this proposal seriously and
all your discussions shed light on the pro's and cons
(well, more cons than pros, to be honest).
It occurrs to me that this proposal is not a sound
one, for the reasons already well documented in
this thread, which I need not repeat.
On 9/25/2010 4:45 AM, Thomas Jollans wrote:
On Saturday 25 September 2010, it occurred to Yingjie Lan to exclaim:
Hi,
I noticed that in python3k, multiplying a sequence by a negative integer is
the same as multiplying it by 0, and the result is an empty sequence. It
seems to me that there is a
58 matches
Mail list logo