Python sets.

Discussion in 'Python' started by Grzegorz Dostatni, May 4, 2004.

  1. I've got a problem.

    Some time ago (I'm a bit fuzzy about the date) I read about sets in
    python. I even tried the code. I remember it was something fairly simple -
    just a base data type (like list or dictionary). I vaguely remember it
    had a syntax similar to creating dictionaries.

    Problem is I can't find it anymore. I've searched around, but it doesn't
    seem to exist. I know of "import sets" and creating classes like that, but
    I'm sure it was a base data type. No import necessary. There were
    operators for basic set operations like set difference, division, etc.

    Please tell me I'm not loosing my mind. Please tell me that these kind of
    things did/still exist?

    Greg


    Advice is what we ask for when we already know the answer but wish we
    didn't.
    -- Erica Jong (How to Save Your Own Life, 1977)
    Grzegorz Dostatni, May 4, 2004
    #1
    1. Advertising

  2. Grzegorz Dostatni wrote:
    > Please tell me I'm not loosing my mind. Please tell me that these kind of
    > things did/still exist?


    while this is bad news for you - it looks like you lost your mind. AFAIK a
    builtin-syntax for lists has been discussed, but I have no idea what the
    outcome of that discussion has been.

    And the sets-module supports the operators by overloading.
    --
    Regards,

    Diez B. Roggisch
    Diez B. Roggisch, May 4, 2004
    #2
    1. Advertising

  3. Grzegorz Dostatni wrote:
    > I've got a problem.
    >
    > Some time ago (I'm a bit fuzzy about the date) I read about sets in
    > python. I even tried the code. I remember it was something fairly simple -
    > just a base data type (like list or dictionary). I vaguely remember it
    > had a syntax similar to creating dictionaries.
    >
    > Problem is I can't find it anymore. I've searched around, but it doesn't
    > seem to exist. I know of "import sets" and creating classes like that, but
    > I'm sure it was a base data type. No import necessary. There were
    > operators for basic set operations like set difference, division, etc.
    >

    I guess you're talking about built-in set type.
    But be warned that it will be introduced in Python 2.4, so if you want
    to try it right now, you need to compile it with yourself from the CVS
    source tree.

    Following links might help:
    * PEP : Adding a Built-In Set Object Type
    http://www.python.org/peps/pep-0218.html
    * What's New in Python 2.4 : Built-In Set Objects
    http://www.python.org/dev/doc/devel/whatsnew/node2.html

    -- George
    George Yoshida, May 4, 2004
    #3
  4. Grzegorz Dostatni wrote:
    > I've got a problem.
    >
    > Some time ago (I'm a bit fuzzy about the date) I read about sets in
    > python. I even tried the code. I remember it was something fairly simple -
    > just a base data type (like list or dictionary). I vaguely remember it
    > had a syntax similar to creating dictionaries.
    >
    > Problem is I can't find it anymore. I've searched around, but it doesn't
    > seem to exist. I know of "import sets" and creating classes like that, but
    > I'm sure it was a base data type. No import necessary. There were
    > operators for basic set operations like set difference, division, etc.


    You might have read "What's New in Python 2.4" which, as of now, really
    explains what is *going* to be new in Python 2.4.

    --
    Shalabh
    Shalabh Chaturvedi, May 5, 2004
    #4
  5. Grzegorz Dostatni

    Dave Reed Guest

    On Tuesday 04 May 2004 21:04, Shalabh Chaturvedi wrote:
    > Grzegorz Dostatni wrote:
    > > I've got a problem.
    > >
    > > Some time ago (I'm a bit fuzzy about the date) I read about sets in
    > > python. I even tried the code. I remember it was something fairly

    simple -
    > > just a base data type (like list or dictionary). I vaguely remember

    it
    > > had a syntax similar to creating dictionaries.
    > >
    > > Problem is I can't find it anymore. I've searched around, but it

    doesn't
    > > seem to exist. I know of "import sets" and creating classes like

    that, but
    > > I'm sure it was a base data type. No import necessary. There were
    > > operators for basic set operations like set difference, division,

    etc.
    >
    > You might have read "What's New in Python 2.4" which, as of now,

    really
    > explains what is *going* to be new in Python 2.4.
    >
    > --
    > Shalabh


    There's also a Set type in Python 2.3 although it may be changing in
    2.4.

    > python

    Python 2.3 (#1, Jul 30 2003, 11:37:39)
    [GCC 3.2.3] on sunos5
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import sets
    >>> dir(sets)

    ['BaseSet', 'ImmutableSet', 'Set', '_TemporarilyImmutableSet',
    '__all__', '__builtins__', '__doc__', '__file__', '__name__',
    'ifilter', 'ifilterfalse']
    >>> s = sets.Set([1, 2, 3])
    >>> s

    Set([1, 2, 3])
    >>>
    Dave Reed, May 5, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sapsi

    Sets in Python

    sapsi, Sep 19, 2007, in forum: Python
    Replies:
    33
    Views:
    890
    sapsi
    Sep 22, 2007
  2. Mr.SpOOn

    Ordering python sets

    Mr.SpOOn, Oct 22, 2008, in forum: Python
    Replies:
    31
    Views:
    1,012
    Mr.SpOOn
    Nov 6, 2008
  3. Tim Chase

    Re: Ordering python sets

    Tim Chase, Oct 22, 2008, in forum: Python
    Replies:
    8
    Views:
    495
    Peter Otten
    Oct 22, 2008
  4. Virgil Stokes

    "Deprecated sets module" with Python 2.6

    Virgil Stokes, Jul 28, 2009, in forum: Python
    Replies:
    4
    Views:
    652
    Virgil Stokes
    Jul 29, 2009
  5. Gabriel Genellina

    Re: "Deprecated sets module" with Python 2.6

    Gabriel Genellina, Jul 29, 2009, in forum: Python
    Replies:
    1
    Views:
    494
    Giampaolo Rodola'
    Jul 29, 2009
Loading...

Share This Page