Op 2005-03-27, Joal Heagney schreef [EMAIL PROTECTED]:
Antoon Pardon wrote:
snip
So python choose a non-deterministic direction. To me (2,3) + (4,5)
equals (6,8). I don't dispute that having an operator to combine
(2,3) and (4,5) in (2,3,4,5) is usefull, but they should never have
used the +
Antoon == Antoon Pardon [EMAIL PROTECTED] writes:
Antoon Op 2005-03-27, Joal Heagney schreef [EMAIL PROTECTED]:
Antoon Pardon wrote:
snip
So python choose a non-deterministic direction. To me (2,3) + (4,5)
equals (6,8). I don't dispute that having an operator to combine
Ville == Ville Vainio [EMAIL PROTECTED] writes:
Ville To me, nothing is more natural than ab + cd ==
Ville abcd. Also [1,2] + [3,4] == [1,2,3,4]. Dot product is
Ville not really too useful in real world (non-mathematical)
Ville apps.
... and of course by dot product, I don't
Op 2005-03-29, Ville Vainio schreef [EMAIL PROTECTED]:
Antoon == Antoon Pardon [EMAIL PROTECTED] writes:
Antoon Op 2005-03-27, Joal Heagney schreef [EMAIL PROTECTED]:
Antoon Pardon wrote:
snip
So python choose a non-deterministic direction. To me (2,3) + (4,5)
equals
Antoon Pardon wrote:
snip
So python choose a non-deterministic direction. To me (2,3) + (4,5)
equals (6,8). I don't dispute that having an operator to combine
(2,3) and (4,5) in (2,3,4,5) is usefull, but they should never have
used the + for that.
(alph, bravo) + (delta, max) -- (alphdelta,
On 15 Mar 2005 11:25:15 -0500, rumours say that [EMAIL PROTECTED] (Roy
Smith) might have written:
The big question is, is it the parens that make it a tuple, or is it
the comma? If you go along with the parens school of thought, then
(1,) is the special case. If you believe in commas, then the
Antoon Pardon wrote:
for instance I have written once somekind of vector class where
it was natural for these vectors to be added as well as te be
concatenated. Unfortunately python uses + for both so I had
no way to have both operators in a natural way in python.
Yes this is a quite common
Op 2005-03-17, Diez B. Roggisch schreef [EMAIL PROTECTED]:
So python choose a non-deterministic direction. To me (2,3) + (4,5)
equals (6,8). I don't dispute that having an operator to combine
(2,3) and (4,5) in (2,3,4,5) is usefull, but they should never have
used the + for that.
It
Op 2005-03-16, Daniel Dittmar schreef [EMAIL PROTECTED]:
Diez B. Roggisch wrote:
I reread his example and have to admit I'm confused: He complains about
having written his _own_ vector class - and concatenation and addition had
to use both + ?
I've interpreted it as:
If Python had choosen
Antoon Pardon wrote:
My peeve is about having operators added to standard types. This
increases the chances that using an object the wrong way leads to a
bogus result, not a runtime error. A more common programming error I
commit is passing a string where a list ist expected. And then I wonder
Op 2005-03-18, Daniel Dittmar schreef [EMAIL PROTECTED]:
Antoon Pardon wrote:
My peeve is about having operators added to standard types. This
increases the chances that using an object the wrong way leads to a
bogus result, not a runtime error. A more common programming error I
commit is
Kay Schluehr wrote:
On the other hand i find Mathematicas list operators very appealing:
In =: [1,2,3]^2
Out=: [1,4,9]
Compared with this suggar the list comprehension [x**2 for x in
[1,2,3]]
is ugly.
py import numarray
py a = numarray.array([1, 2, 3])
py a**2
array([1, 4, 9])
STeVe
--
Op 2005-03-16, Diez B. Roggisch schreef [EMAIL PROTECTED]:
That ambiguity is only caused because python uses the same characters
for very different operations and to be honest I don't like that.
As I said: show me which parentheses to use - and keep in mind that:
- and are for
So python choose a non-deterministic direction. To me (2,3) + (4,5)
equals (6,8). I don't dispute that having an operator to combine
(2,3) and (4,5) in (2,3,4,5) is usefull, but they should never have
used the + for that.
It certainly did not choose a nondeterministic action - that would mean
Gregor Horvath [EMAIL PROTECTED] wrote:
type(['1'])
type 'list'
type(('1'))
type 'str'
I wonder why ('1') is no tuple
There were lots of answers, but I'm not sure I saw the why addressed.
Consider this:
a = (3 + 5) * 5
You really, really want (3 + 5) to be an integer, not a
Op 2005-03-16, Tim Roberts schreef [EMAIL PROTECTED]:
Gregor Horvath [EMAIL PROTECTED] wrote:
type(['1'])
type 'list'
type(('1'))
type 'str'
I wonder why ('1') is no tuple
There were lots of answers, but I'm not sure I saw the why addressed.
Consider this:
a = (3 + 5) * 5
You
Consider this:
a = (3 + 5) * 5
You really, really want (3 + 5) to be an integer, not a one-item tuple.
I sometimes do wonder if some impliciteness wouldn't be better here,
so that any item could be treated as if it was a one-item tuple.
A bit like every char being a string.
There
Op 2005-03-16, Diez B. Roggisch schreef [EMAIL PROTECTED]:
Consider this:
a = (3 + 5) * 5
You really, really want (3 + 5) to be an integer, not a one-item tuple.
I sometimes do wonder if some impliciteness wouldn't be better here,
so that any item could be treated as if it was a
That ambiguity is only caused because python uses the same characters
for very different operations and to be honest I don't like that.
As I said: show me which parentheses to use - and keep in mind that:
- and are for comparisions and the same ambiguity troubles arise
- unicode surely
Diez B. Roggisch wrote:
for instance I have written once somekind of vector class where
it was natural for these vectors to be added as well as te be
concatenated. Unfortunately python uses + for both so I had
no way to have both operators in a natural way in python.
And no way in mathematics or
Daniel Dittmar wrote:
But what the heck, I find list comprehension rather awful.
Sacrilege! ;)
STeVe
--
http://mail.python.org/mailman/listinfo/python-list
I think he meant that Python should have introduced different operators
for addition and sequence concatenation.
I reread his example and have to admit I'm confused: He complains about
having written his _own_ vector class - and concatenation and addition had
to use both + ?
He could have used
Diez B. Roggisch wrote:
I reread his example and have to admit I'm confused: He complains about
having written his _own_ vector class - and concatenation and addition had
to use both + ?
I've interpreted it as:
If Python had choosen different operators for addition and sequence
concatenation, I
On Wednesday 16 March 2005 07:22 am, Diez B. Roggisch wrote:
As I said: show me which parentheses to use
I kind of like the comma as a tuple parentheses
,1,2,3,
replacing
(1,2,3)
or
1,2,3,
or
1,2,3
or (isn't this is getting out of hand?)
(1,2,3,)
Why not--except of course for backward
James Stroud wrote:
On Wednesday 16 March 2005 07:22 am, Diez B. Roggisch wrote:
As I said: show me which parentheses to use
I kind of like the comma as a tuple parentheses
,1,2,3,
replacing
(1,2,3)
or
1,2,3,
or
1,2,3
or (isn't this is getting out of hand?)
(1,2,3,)
Why not--except of course for
On Wednesday 16 March 2005 04:45 pm, Robert Kern wrote:
This would be very unambiguous.
Not entirely.
Then, the purity would manifest itself the naked comma being an empty
tuple. Think about the zen of:
,
Is that a tuple or grit on my monitor? :-)
OK, OK, I'll give up on the
On Wed, 16 Mar 2005 17:28:51 -0800, James Stroud wrote:
On Wednesday 16 March 2005 04:45 pm, Robert Kern wrote:
This would be very unambiguous.
Not entirely.
Then, the purity would manifest itself the naked comma being an empty
tuple. Think about the zen of:
,
Is that a tuple or
Hi,
type(['1'])
type 'list'
type(('1'))
type 'str'
I wonder why ('1') is no tuple
Because I have to treat this special case differently in my code.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
('1',) is a tuple... you need the comma to make it a tuple.
regards,
Fuzzy
http://www.voidspace.org.uk/python/index.shtml
--
http://mail.python.org/mailman/listinfo/python-list
Title: RE: Why tuple with one item is no tuple
[Gregor Horvath]
#- type(('1'))
#- type 'str'
#-
#- I wonder why ('1') is no tuple
The parentheses don't create the tuple, the comma does:
('1')
'1'
('1',)
('1',)
'1',
('1',)
. Facundo
Bitácora De Vuelo: http
On Tue, 15 Mar 2005 16:16:34 GMT, Gregor Horvath [EMAIL PROTECTED] wrote:
Hi,
type(['1'])
type 'list'
type(('1'))
type 'str'
I wonder why ('1') is no tuple
because, syntactically, those parens are for grouping, and do not
unambiguously define a tuple. It's a python gotcha. To
Gregor Horvath wrote:
Hi,
type(['1'])
type 'list'
type(('1'))
type 'str'
I wonder why ('1') is no tuple
Because I have to treat this special case differently in my code.
you need to tell python that ('1') isn't a string inside
a couple parens but a tuple, look:
t = ('1', )
type(t)
type
Gregor Horvath [EMAIL PROTECTED] wrote:
Hi,
type(['1'])
type 'list'
type(('1'))
type 'str'
I wonder why ('1') is no tuple
You need to say ('1',). In just plain ('1'), the parens are
interpreted as grouping, not as tuple creation. Depending on your
point of view, this is either a
thanks are given to all
problem solved...
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
Hmm,
going 'the other way', you are allowed an extra , but you can't have
(,) as the empty tuple.:
(1,2,)
(1, 2)
(1,)
(1,)
(,)
...
Traceback ( File interactive input, line 1
(,)
^
SyntaxError: invalid syntax
-- Pad.
--
http://mail.python.org/mailman/listinfo/python-list
On Tuesday 15 March 2005 08:25 am, Roy Smith wrote:
a = () # tuple of zero elements
a = (1,) # tuple of one element
a = 1, # tuple of one element
a = (1) # scalar
a = (1, 2) # tuple of two elements
a = 1, 2 # tuple of two elements
a = , # syntax error
The
On Tue, 15 Mar 2005 10:47:28 -0800, James Stroud [EMAIL PROTECTED] wrote:
On Tuesday 15 March 2005 08:25 am, Roy Smith wrote:
a = () # tuple of zero elements
a = (1,) # tuple of one element
a = 1, # tuple of one element
a = (1) # scalar
a = (1, 2) # tuple of two
Bill Mill wrote:
On Tue, 15 Mar 2005 10:47:28 -0800, James Stroud [EMAIL PROTECTED] wrote:
On Tuesday 15 March 2005 08:25 am, Roy Smith wrote:
a = () # tuple of zero elements
a = (1,) # tuple of one element
a = 1, # tuple of one element
a = (1) # scalar
a = (1, 2)
Gregor Horvath wrote:
thanks are given to all
problem solved...
Personally I add a , after every list/tuple item. Also the last.
It also makes copy/pasting code easier.
--
hilsen/regards Max M, Denmark
http://www.mxm.dk/
IT's Mad Science
--
http://mail.python.org/mailman/listinfo/python-list
39 matches
Mail list logo