"Life was like a box of chocolates. You never know what you're gonna
get."
Regardless of how it is implemented, mathematically a set is a
collection of items.
The order does not matter, an item is part of a set, or is not part of
a set. Period.
Henk
--
http://mail.python.org/mailman/listinfo/py
In message <[EMAIL PROTECTED]>, Steven D'Aprano
wrote:
> On Sun, 05 Oct 2008 22:11:38 +1300, Lawrence D'Oliveiro wrote:
>
>> In message <[EMAIL PROTECTED]>, Steven D'Aprano
>> wrote:
>>
>>> Would it really be "confusing" if sets used the same interface as dicts
>>> use? I don't think so. What el
Bruno Desthuilliers wrote:
Steven D'Aprano a écrit :
On Sat, 04 Oct 2008 18:36:28 +0200, Bruno Desthuilliers wrote:
Lists are the odd one out, because del alist[x] is used to remove the
element at position x, rather than removing an element x.
Nope. It's perfectly consistent with dicts, wher
Steven D'Aprano a écrit :
On Sun, 05 Oct 2008 22:11:38 +1300, Lawrence D'Oliveiro wrote:
In message <[EMAIL PROTECTED]>, Steven D'Aprano
wrote:
Would it really be "confusing" if sets used the same interface as dicts
use? I don't think so. What else could "del aset[x]" mean other than
"delete
Steven D'Aprano a écrit :
On Sat, 04 Oct 2008 18:36:28 +0200, Bruno Desthuilliers wrote:
Yes I know that sets have a remove method (like lists), but since
dictionaries don't have a remove method, shouldn't sets behave like
more like dictionaries and less like lists? IMHO del for sets is quite
On Sun, 05 Oct 2008 22:11:38 +1300, Lawrence D'Oliveiro wrote:
> In message <[EMAIL PROTECTED]>, Steven D'Aprano
> wrote:
>
>> Would it really be "confusing" if sets used the same interface as dicts
>> use? I don't think so. What else could "del aset[x]" mean other than
>> "delete element x"?
>
In message <[EMAIL PROTECTED]>, Steven D'Aprano
wrote:
> Would it really be "confusing" if sets used the same interface as dicts
> use? I don't think so. What else could "del aset[x]" mean other than
> "delete element x"?
Yes, but "x" in what sense? In dicts it's a key, in sets, shouldn't it also
On Sat, 04 Oct 2008 18:36:28 +0200, Bruno Desthuilliers wrote:
>> Yes I know that sets have a remove method (like lists), but since
>> dictionaries don't have a remove method, shouldn't sets behave like
>> more like dictionaries and less like lists? IMHO del for sets is quite
>> intuitive.
>
> F
Larry Bates a écrit :
You can do the following:
a = [1,2,3,4,5]
del a[0]
and
a = {1:'1', 2: '2', 3: '3', 4:'4', 5:'5'}
del a[1]
why doesn't it work the same for sets (particularly since sets are based
on a dictionary)?
a = set([1,2,3,4,5])
del a[1]
>
Yes I know that sets have a remove met
On Fri, 03 Oct 2008 02:09:09 -0700, Carl Banks wrote:
> On Oct 2, 8:02 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>> Then add subscription access too. By aliasing `__getitem__()` to
>> `__contains__()`. And `__setitem__()` could be implemented to add or
>> remove objects by assignin
Steven D'Aprano:
> Personally, I'd rather see dictionaries grow methods like
> symmetric_difference, union, etc. than worry about whether you use del or
> remove to remove elements from a set.
I have functions for all those operations, so I think they can be
useful, but in practice I don't use the
On Fri, 03 Oct 2008 02:18:53 -0700, Carl Banks wrote:
> On Oct 2, 11:27 pm, Larry Bates <[EMAIL PROTECTED]> wrote:
>> I didn't mean to imply that del a[1] would delete the first thing in
>> the set, but rather the item with a value of 1. Just as when we use it
>> on a dictionary:
>>
>> del a[1]
>
On Oct 2, 11:27 pm, Larry Bates <[EMAIL PROTECTED]> wrote:
> I didn't mean to imply that del a[1] would delete the first thing in the set,
> but rather the item with a value of 1. Just as when we use it on a
> dictionary:
>
> del a[1]
>
> doesn't mean delete the first dictionary entry but rather
On Oct 2, 8:02 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> On Thu, 02 Oct 2008 15:39:55 -0700, Chris Rebert wrote:
> > On Thu, Oct 2, 2008 at 3:20 PM, Larry Bates <[EMAIL PROTECTED]>
> > wrote:
> >> a = set([1,2,3,4,5])
> >> del a[1]
>
> > Sets don't support subscripting, so if you ca
On Thu, 02 Oct 2008 22:27:04 -0500, Larry Bates wrote:
> Maybe dictionaries should have had a .remove method then things would be
> more consistent?
But why should sets be consistent with dictionaries? There are a few
similarities, but also differences.
Personally, I'd rather see dictionaries g
On Oct 2, 6:20 pm, Larry Bates <[EMAIL PROTECTED]> wrote:
> You can do the following:
>
> a = [1,2,3,4,5]
> del a[0]
>
> and
>
> a = {1:'1', 2: '2', 3: '3', 4:'4', 5:'5'}
> del a[1]
>
> why doesn't it work the same for sets (particularly since sets are based on a
> dictionary)?
>
> a = set([1,2,3,
Chris Hebert wrote:
On Thu, Oct 2, 2008 at 3:20 PM, Larry Bates <[EMAIL PROTECTED]> wrote:
You can do the following:
a = [1,2,3,4,5]
del a[0]
and
a = {1:'1', 2: '2', 3: '3', 4:'4', 5:'5'}
del a[1]
why doesn't it work the same for sets (particularly since sets are based on
a dictionary)?
a =
On Thu, 02 Oct 2008 15:39:55 -0700, Chris Rebert wrote:
> On Thu, Oct 2, 2008 at 3:20 PM, Larry Bates <[EMAIL PROTECTED]>
> wrote:
>> a = set([1,2,3,4,5])
>> del a[1]
>
> Sets don't support subscripting, so if you can't go 'a_set[something]',
> why would you expect to be able to be able to 'del'
Chris Rebert:
> No, sets are a datatype unto themselves. They are based on
> dictionaries internally (at least in CPython), but that's an
> implemention detail to be hidden, not emphasized.
Later Hettinger has simplified their code, making them use less memory
(and be a little faster too, I think)
On Thu, 02 Oct 2008 16:48:42 -0700, Jon Clements wrote:
> It's also worth noting that removing an object from a container
> (.remove) is different than proposing the object goes to GC (del...)
``del`` doesn't propose that the object goes to GC, at least not more
then a `remove()` method does. J
On Oct 2, 11:20 pm, Larry Bates <[EMAIL PROTECTED]> wrote:
> You can do the following:
>
> a = [1,2,3,4,5]
> del a[0]
>
> and
>
> a = {1:'1', 2: '2', 3: '3', 4:'4', 5:'5'}
> del a[1]
>
> why doesn't it work the same for sets (particularly since sets are based on a
> dictionary)?
>
> a = set([1,2,3,
On Thu, Oct 2, 2008 at 3:20 PM, Larry Bates <[EMAIL PROTECTED]> wrote:
> You can do the following:
>
> a = [1,2,3,4,5]
> del a[0]
>
> and
>
> a = {1:'1', 2: '2', 3: '3', 4:'4', 5:'5'}
> del a[1]
>
> why doesn't it work the same for sets (particularly since sets are based on
> a dictionary)?
>
> a =
You can do the following:
a = [1,2,3,4,5]
del a[0]
and
a = {1:'1', 2: '2', 3: '3', 4:'4', 5:'5'}
del a[1]
why doesn't it work the same for sets (particularly since sets are based on a
dictionary)?
a = set([1,2,3,4,5])
del a[1]
Yes I know that sets have a remove method (like lists), but sin
23 matches
Mail list logo