Terry Reedy wrote:
> You might so define, but Bryan and others might not. The
> philosophical/methodological idea that 'everything is a set' has been very
> fruitful but it is not a fact. Alternative ideas are 'everything is a
> function' and 'everything is defined by axioms'.
according to goog
"Christoph Zwerschke" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Bryan Olson wrote:
>> The claim "everything is a set" falls into the category of
>> 'not even wrong'.
>
> No, it falls into the category of the most fundamental Mathematical
> concepts. You actually *define* tuple
I think this has been discussed thoroughgoing enough. All I wanted to
say is that this proposal of building "Cartesian products" of strings is
well-defined, in line with the mathematical concept of Cartesian
products, and can be *sometimes* useful. I hope we agree on this, but if
not we don't n
Christoph Zwerschke wrote:
> Bryan Olson wrote:
>
>> The claim "everything is a set" falls into the category of
>> 'not even wrong'.
>
> No, it falls into the category of the most fundamental Mathematical
> concepts. You actually *define* tuples as sets, or functions as sets or
> relations as s
Bryan Olson wrote:
> The claim "everything is a set" falls into the category of
> 'not even wrong'.
No, it falls into the category of the most fundamental Mathematical
concepts. You actually *define* tuples as sets, or functions as sets or
relations as sets, or even all kinds of numbers and ot
Bryan Olson wrote:
> The claim "everything is a set" falls into the category of
> 'not even wrong'.
No, it falls into the category of the most fundamental Mathematical
concepts. You actually *define* tuples as sets, or functions as sets or
relations as sets, or even all kinds of numbers and othe
Christoph Zwerschke wrote:
> Bryan Olson schrieb:
>
>>> Still think there is no such thing?
>>
>>
>> Uh, yes.
>>
>>The Cartesian product of two sets A and B (also called the
>>product set, set direct product, or cross product) is defined to
>>be the set of [...]
>>
>> All sets, no stri
Christoph Zwerschke wrote:
> Now as I'm thinking about it, wouldn't it be nice to have the cartesian
> products on Python sets? Maybe also a method that returns the power set
> of a set (the set of all subsets), or the set of all subsets with a
> given length.
For defining powersets it might suf
Christoph Zwerschke wrote:
> Bryan Olson schrieb:
>
>>> Still think there is no such thing?
>>
>>
>> Uh, yes.
>>
>>The Cartesian product of two sets A and B (also called the
>>product set, set direct product, or cross product) is defined to
>>be the set of [...]
>>
>> All sets, no stri
Kay Schluehr wrote:
> Bryan Olson wrote:
>
>
>>There's no such thing; you'd have to define it first. Are duplicates
>>significant? Order?
>
>
> That's all trivial isn't it? A string is a set of pairs (i,c) where i
> is an integer number, the index, with 0<=i (i,c), (j,d) in string and c is a ch
Steven D'Aprano wrote:
> On Mon, 23 Jan 2006 18:17:08 +, Bryan Olson wrote:
>
>
>>Steven D'Aprano wrote:
>>
>>>Bryan Olson wrote:
>>>
>>[Christoph Zwerschke had written:]
>>
>What I expect as the result is the "cartesian product" of the strings.
There's no such thing; you'd have
Bryan Olson schrieb:
>> Still think there is no such thing?
>
> Uh, yes.
>
>The Cartesian product of two sets A and B (also called the
>product set, set direct product, or cross product) is defined to
>be the set of [...]
>
> All sets, no strings. What were you looking at?
Not only
Steven D'Aprano wrote:
> On Mon, 23 Jan 2006 18:17:08 +, Bryan Olson wrote:
>
> > Steven D'Aprano wrote:
> >> Bryan Olson wrote:
> >>
> >>
> > [Christoph Zwerschke had written:]
> What I expect as the result is the "cartesian product" of the strings.
> >>>
> >>>There's no such thing; you'd
On Mon, 23 Jan 2006 18:17:08 +, Bryan Olson wrote:
> Steven D'Aprano wrote:
>> Bryan Olson wrote:
>>
>>
> [Christoph Zwerschke had written:]
What I expect as the result is the "cartesian product" of the strings.
>>>
>>>There's no such thing; you'd have to define it first. Are duplicates
Bryan Olson wrote:
> There's no such thing; you'd have to define it first. Are duplicates
> significant? Order?
That's all trivial isn't it? A string is a set of pairs (i,c) where i
is an integer number, the index, with 0<=ihttp://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano wrote:
> Bryan Olson wrote:
>
>
[Christoph Zwerschke had written:]
>>>What I expect as the result is the "cartesian product" of the strings.
>>
>>There's no such thing; you'd have to define it first. Are duplicates
>>significant? Order?
>
>
> Google "cartesian product" and hit "
Steven D'Aprano wrote:
> Bryan Olson wrote:
>>Christoph Zwerschke wrote:
>>[...]
>>
>>>That may be the main problem to decide whether the cartesian product
>>>should return a generator or a list.
>>
>>The Cartesion product is a set.
>
> And the generalization of mathematical sets in Python can be
Bryan Olson schrieb:
> Christoph Zwerschke wrote:
> [...]
>> That may be the main problem to decide whether the cartesian product
>> should return a generator or a list.
>
> The Cartesion product is a set.
Of course it is a set. But if the factors of the product have a total
order (as in the ca
Bryan Olson wrote:
> Christoph Zwerschke wrote:
> [...]
>> That may be the main problem to decide whether the cartesian product
>> should return a generator or a list.
>
> The Cartesion product is a set.
Sets are iterable, so that isn't an answer. If it's a set, then it
should either be a gen
On Mon, 23 Jan 2006 10:36:55 +, Bryan Olson wrote:
> Christoph Zwerschke wrote:
> [...]
>> That may be the main problem to decide whether the cartesian product
>> should return a generator or a list.
>
> The Cartesion product is a set.
And the generalization of mathematical sets in Python c
On Mon, 23 Jan 2006 01:25:36 +, Bryan Olson wrote:
>> Sometimes I was missing such a feature.
>> What I expect as the result is the "cartesian product" of the strings.
>
> There's no such thing; you'd have to define it first. Are duplicates
> significant? Order?
Google "cartesian product" an
Christoph Zwerschke wrote:
[...]
> That may be the main problem to decide whether the cartesian product
> should return a generator or a list.
The Cartesion product is a set.
[...]
> That's the other problem. The uses cases (like the password cracker
> example) are very limited and in these cas
Jean-Paul Calderone wrote:
> Christoph Zwerschke <[EMAIL PROTECTED]> wrote:
>>
>> BTW: What is the shortest way to get the binary representation of a
>> number in Python? Is there really not something like itoa() anywhere in
>> the standard libs?
>
> I'm somewhat partial to this implementation:
>
On Mon, 23 Jan 2006 03:21:59 +0100, Christoph Zwerschke <[EMAIL PROTECTED]>
wrote:
>
>BTW: What is the shortest way to get the binary representation of a
>number in Python? Is there really not something like itoa() anywhere in
>the standard libs?
I'm somewhat partial to this implementation:
bina
Bryan Olson wrote:
> What you seem to want is easy enough:
> [a + b for a in 'hello' for b in 'world']
Yes, but 'hello'*'world' is easier.
And how would you write '01'**8 ? This should give you all bytes in
binary code.
> And maybe you want the result to be a generator:
> (a + b for a in
Christoph Zwerschke wrote:
> In Python, it is possible to multiply a string with a number:
>
> >>> "hello"*3
> 'hellohellohello'
Which is really useful.
> However, you can't multiply a string with another string:
>
> >>> 'hello'*'world'
> Traceback (most recent call last):
> File "", line 1
Steven D'Aprano wrote:
> If you are happy to always return a list of tuples regardless of what the
> two operands are, generators make it so easy it is shameful. Even if you
> want a special case of two string arguments returning a string, it is
> hardly any more difficult:
>
> def cartprod(A, B):
On Sun, 22 Jan 2006 19:12:49 +0100, Christoph Zwerschke wrote:
> Steven D'Aprano wrote:
>> On Sun, 22 Jan 2006 18:29:45 +0100, Christoph Zwerschke wrote:
>>> For doing such things I would use a vector subtype of list.
>>
>> Not everything needs to be a separate class! Why create a magic class for
Steven D'Aprano wrote:
> I beg to differ: Python *allows* people to create classes if they're keen
> on the syntax (and I can sympathise with that like), but Python
> *encourages* by example generic tools that operate on as many different
> types as makes sense.
But these generic tools (say the "p
Alex Martelli schrieb:
>> s = set(range(49)).powerset(6)
>> for x in range(10):
>> print s.pop()
>
> This is very systematic, not random;-). Still, using random.sample on s
> would indeed produce 12 random different tips!-)
Right, that would be systematic. What I wanted to write was:
s = s
On Sun, 22 Jan 2006 10:41:39 -0800, Alex Martelli wrote:
> Steven D'Aprano <[EMAIL PROTECTED]> wrote:
>...
>> What advantage is there to creating a "list with cartesian product"
>> subclass of list?
>
> Essentially, syntax sugar -- for some people, being able to code a*b
> rather than product
Generally, if you could multiply strings in the above fashion, you could
spare one more more sub loops, as in this example:
for f in ('index', 'default')*('.html', '.htm', '.shtml'):
if exists(f):
break
In this case, it would be not really be better than that:
for f in '
Christoph Zwerschke <[EMAIL PROTECTED]> wrote:
> Alex Martelli schrieb:
> > Christoph Zwerschke <[EMAIL PROTECTED]> wrote:
> >...
> >> given length. You could get a 6/49 lotto tip with something like:
> >>
> >> choice(set(range(49)).powerset(6))
>
> > And that would be better than the current
Steven D'Aprano <[EMAIL PROTECTED]> wrote:
...
> What advantage is there to creating a "list with cartesian product"
> subclass of list?
Essentially, syntax sugar -- for some people, being able to code a*b
rather than product(a,b) takes on a huge significance; Python chooses to
support this syn
Christoph Zwerschke <[EMAIL PROTECTED]> writes:
> No, the elements of the powerset would be sets with 6 elements each,
> not tuples. So technically, it would be correct. Just horribly
> inefficient.
Oh I see, not the Cartesian product. Yeah, it would be silly in
practice.
--
http://mail.python.o
Paul Rubin schrieb:
> [EMAIL PROTECTED] (Alex Martelli) writes:
>>> given length. You could get a 6/49 lotto tip with something like:
>>> choice(set(range(49)).powerset(6))
>> And that would be better than the current random.sample(range(49),6) in
>> WHAT ways, exactly...?
>
> I think the first on
Steven D'Aprano wrote:
> On Sun, 22 Jan 2006 18:29:45 +0100, Christoph Zwerschke wrote:
>> For doing such things I would use a vector subtype of list.
>
> Not everything needs to be a separate class! Why create a magic class for
> every piece of functionality you want? Just create functions that o
Alex Martelli schrieb:
> Christoph Zwerschke <[EMAIL PROTECTED]> wrote:
>...
>> given length. You could get a 6/49 lotto tip with something like:
>>
>> choice(set(range(49)).powerset(6))
> And that would be better than the current random.sample(range(49),6) in
> WHAT ways, exactly...?
You're
On Sun, 22 Jan 2006 18:29:45 +0100, Christoph Zwerschke wrote:
> Alex Martelli wrote:
>> Kay Schluehr <[EMAIL PROTECTED]> wrote:
>>> range(3)**2
>>> But why isn't this interpreted as [0, 1, 4] like it is in Mathematica?
>>
>> Since range(3)*2 is [0, 1, 2, 0, 1, 2], it would be horribly, painfully
[EMAIL PROTECTED] (Alex Martelli) writes:
> > given length. You could get a 6/49 lotto tip with something like:
> > choice(set(range(49)).powerset(6))
>
> And that would be better than the current random.sample(range(49),6) in
> WHAT ways, exactly...?
I think the first one would be incorrect sinc
Christoph Zwerschke <[EMAIL PROTECTED]> wrote:
...
> given length. You could get a 6/49 lotto tip with something like:
>
> choice(set(range(49)).powerset(6))
And that would be better than the current random.sample(range(49),6) in
WHAT ways, exactly...?
Alex
--
http://mail.python.org/mailman
Alex Martelli wrote:
> Kay Schluehr <[EMAIL PROTECTED]> wrote:
>> range(3)**2
>> But why isn't this interpreted as [0, 1, 4] like it is in Mathematica?
>
> Since range(3)*2 is [0, 1, 2, 0, 1, 2], it would be horribly, painfully
> inconsistent if **2 was interpreted as "square each item".
Yes. Pyt
Kay Schluehr schrieb:
> But why isn't this interpreted as [0, 1, 4] like it is in Mathematica?
Because we are thinking of a cartesian product. If you have lists of
numbers, then there are mane more ways to define a product: tensor
product, vector product, scalar product, componentwise product...
Kay Schluehr <[EMAIL PROTECTED]> wrote:
...
> > >> range(3)**2
> > [(0,0), (0,1), (0,2), (1,0), (1,1), (1,2), (2,0), (2,1), (2,2)]
...
> But why isn't this interpreted as [0, 1, 4] like it is in Mathematica?
Since range(3)*2 is [0, 1, 2, 0, 1, 2], it would be horribly, painfully
inconsistent
Giovanni Bajo wrote:
> Christoph Zwerschke wrote:
>
> > Sometimes I was missing such a feature.
> > What I expect as the result is the "cartesian product" of the strings.
>
> I've been thinking of it as well. I'd like it for lists too:
>
> >> range(3)**2
> [(0,0), (0,1), (0,2), (1,0), (1,1), (1,2)
Christoph Zwerschke wrote:
> Sometimes I was missing such a feature.
> What I expect as the result is the "cartesian product" of the strings.
I've been thinking of it as well. I'd like it for lists too:
>> range(3)**2
[(0,0), (0,1), (0,2), (1,0), (1,1), (1,2), (2,0), (2,1), (2,2)]
--
Giovanni
In Python, it is possible to multiply a string with a number:
>>> "hello"*3
'hellohellohello'
However, you can't multiply a string with another string:
>>> 'hello'*'world'
Traceback (most recent call last):
File "", line 1, in ?
TypeError: can't multiply sequence by non-int
Sometimes I was
47 matches
Mail list logo