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:
> >>
> >>> So python choose a non-deterministic direction. To me (2,3)
> "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
> "Antoon" == Antoon Pardon <[EMAIL PROTECTED]> writes:
Antoon> Op 2005-03-27, Joal Heagney schreef <[EMAIL PROTECTED]>:
>> Antoon Pardon wrote:
>>
>>> So python choose a non-deterministic direction. To me (2,3) + (4,5)
>>> equals (6,8). I don't dispute that having an oper
Op 2005-03-27, Joal Heagney schreef <[EMAIL PROTECTED]>:
> Antoon Pardon wrote:
>
>> 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
Antoon Pardon wrote:
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 th
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
--
http://ma
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
>>>
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-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 ha
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.
>
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 co
> 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
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
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:
>> >
>> > Â Â
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 giv
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 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 comp
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 co
> 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 use
Daniel Dittmar wrote:
But what the heck, I find list comprehension rather awful.
Sacrilege! ;)
STeVe
--
http://mail.python.org/mailman/listinfo/python-list
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
> 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
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
>> 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
Op 2005-03-16, Tim Roberts schreef <[EMAIL PROTECTED]>:
> Gregor Horvath <[EMAIL PROTECTED]> wrote:
>>
>> >>>type(['1'])
>>
>>
>> >>>type(('1'))
>>
>>
>>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 +
Gregor Horvath <[EMAIL PROTECTED]> wrote:
>
> >>>type(['1'])
>
>
> >>>type(('1'))
>
>
>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 one-item t
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
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) # scal
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) # tu
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
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 "", line 1
(,)
^
SyntaxError: invalid syntax
-- Pad.
--
http://mail.python.org/mailman/listinfo/python-list
thanks are given to all
"problem" solved...
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
Gregor Horvath <[EMAIL PROTECTED]> wrote:
>Hi,
>
> >>>type(['1'])
>
>
> >>>type(('1'))
>
>
>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 "special c
Gregor Horvath wrote:
Hi,
>>>type(['1'])
>>>type(('1'))
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)
if there's no a
On Tue, 15 Mar 2005 16:16:34 GMT, Gregor Horvath <[EMAIL PROTECTED]> wrote:
> Hi,
>
> >>>type(['1'])
>
>
> >>>type(('1'))
>
>
> 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 define
Title: RE: Why tuple with one item is no tuple
[Gregor Horvath]
#- >>>type(('1'))
#-
#-
#- I wonder why ('1') is no tuple
The parentheses don't create the tuple, the comma does:
>>> ('1')
'1'
>>>
('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
Hi,
>>>type(['1'])
>>>type(('1'))
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
39 matches
Mail list logo