builtin set literal

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?ISO-8859-1?Q?Sch=FCle_Daniel?=

    #1

    builtin set literal

    Hello,

    lst = list((1,2,3))
    lst = [1,2,3]

    t = tupel((1,2,3))
    t = (1,2,3)

    s = set((1,2,3))
    s = ...

    it would be nice feature to have builtin literal for set type
    maybe in P3 .. what about?
    s = <1,2,3>

    Regards, Daniel
  • faulkner

    #2
    Re: builtin set literal

    On Feb 14, 11:55 am, Schüle Daniel <u...@rz.uni-karlsruhe.dewro te:
    Hello,
    >
    lst = list((1,2,3))
    lst = [1,2,3]
    >
    t = tupel((1,2,3))
    t = (1,2,3)
    >
    s = set((1,2,3))
    s = ...
    >
    it would be nice feature to have builtin literal for set type
    maybe in P3 .. what about?
    s = <1,2,3>
    >
    Regards, Daniel
    sets aren't quite that useful or common. just use a list.
    and '<' and '>' already have syntactic meanings.
    and that would make python look more like C++, which nobody wants.

    Comment

    • Steven Bethard

      #3
      Re: builtin set literal

      Schüle Daniel wrote:
      Hello,
      >
      lst = list((1,2,3))
      lst = [1,2,3]
      >
      t = tupel((1,2,3))
      t = (1,2,3)
      >
      s = set((1,2,3))
      s = ...
      >
      it would be nice feature to have builtin literal for set type
      maybe in P3 .. what about?
      s = <1,2,3>
      In Python 3.0, this looks like::

      s = {1,2,3}

      More info here:

      This PEP, previously known as PEP 3000, describes smaller scale changes and new features for which no separate PEP is written yet, all targeted for Python 3000.


      STeVe

      Comment

      • =?ISO-8859-1?Q?Sch=FCle_Daniel?=

        #4
        Re: builtin set literal

        faulkner schrieb:
        On Feb 14, 11:55 am, Schüle Daniel <u...@rz.uni-karlsruhe.dewro te:
        >Hello,
        >>
        >lst = list((1,2,3))
        >lst = [1,2,3]
        >>
        >t = tupel((1,2,3))
        >t = (1,2,3)
        >>
        >s = set((1,2,3))
        >s = ...
        >>
        >it would be nice feature to have builtin literal for set type
        >maybe in P3 .. what about?
        >s = <1,2,3>
        >>
        >Regards, Daniel
        >
        sets aren't quite that useful or common. just use a list.
        and '<' and '>' already have syntactic meanings.
        well, I thought about this
        the empty set <has the meaning of != now
        as far as I remember is <depricated and will disappear
        When they are gone in P3000, <could be reused as empty set.
        and that would make python look more like C++, which nobody wants.
        I dont think that actually many people fear this.
        we have {} for dicts and I doubt anybody mistake them for C++ brakets.

        In my previuos post I forgot to mention

        d = dict()
        d = {}

        s = set()
        s = <>

        why not, on the first sight everybody will see ... here our
        algorithmus deals with unique things/objects ... put in a set.

        Regards, Daniel

        Comment

        • =?ISO-8859-1?Q?Sch=FCle_Daniel?=

          #5
          Re: builtin set literal

          Steven Bethard schrieb:
          Schüle Daniel wrote:
          >Hello,
          >>
          >lst = list((1,2,3))
          >lst = [1,2,3]
          >>
          >t = tupel((1,2,3))
          >t = (1,2,3)
          >>
          >s = set((1,2,3))
          >s = ...
          >>
          >it would be nice feature to have builtin literal for set type
          >maybe in P3 .. what about?
          >s = <1,2,3>
          >
          In Python 3.0, this looks like::
          >
          s = {1,2,3}
          jepp, that looks not bad .. as in a mathe book.
          the only disadvantage I see, that one may confuse it with a dict.

          Regards, Daniel

          Comment

          • Steven Bethard

            #6
            Re: builtin set literal

            Schüle Daniel wrote:
            Steven Bethard schrieb:
            >Schüle Daniel wrote:
            >>it would be nice feature to have builtin literal for set type
            >>maybe in P3 .. what about?
            >>s = <1,2,3>
            >>
            >In Python 3.0, this looks like::
            >>
            > s = {1,2,3}
            >
            jepp, that looks not bad .. as in a mathe book.
            the only disadvantage I see, that one may confuse it with a dict.
            Perhaps with a very cursory inspection. But the lack of any ':'
            characters is a pretty quick clue-in.

            STeVe

            Comment

            • =?ISO-8859-1?Q?Sch=FCle_Daniel?=

              #7
              Re: builtin set literal

              [...]
              >>In Python 3.0, this looks like::
              >>>
              >> s = {1,2,3}
              >>
              >jepp, that looks not bad .. as in a mathe book.
              >the only disadvantage I see, that one may confuse it with a dict.
              >
              Perhaps with a very cursory inspection. But the lack of any ':'
              characters is a pretty quick clue-in.
              there is one a bigger disadvantage though
              {} empty set clashes with empty dict {}
              set() still must be used to generate the empty set
              or a hack like
              s = {None}.clear()

              I think something like {-} as the substitution for empty set
              will seem bit to perlish for most of us? :)

              Regards, Daniel

              Comment

              • MRAB

                #8
                Re: builtin set literal

                On Feb 15, 4:12 pm, Schüle Daniel <u...@rz.uni-karlsruhe.dewro te:
                [...]
                >
                >In Python 3.0, this looks like::
                >
                > s = {1,2,3}
                >
                jepp, that looks not bad .. as in a mathe book.
                the only disadvantage I see, that one may confuse it with a dict.
                >
                Perhaps with a very cursory inspection. But the lack of any ':'
                characters is a pretty quick clue-in.
                >
                there is one a bigger disadvantage though
                {} empty set clashes with empty dict {}
                set() still must be used to generate the empty set
                or a hack like
                s = {None}.clear()
                >
                I think something like {-} as the substitution for empty set
                will seem bit to perlish for most of us? :)
                >
                What about "{,}"? For consistency "(,)" and "[,]" might also have to
                be permissible, and maybe even "{:}" for an empty dict. Or perhaps not.

                Comment

                • Raymond Hettinger

                  #9
                  Re: builtin set literal

                  >What about "{,}"? For consistency "(,)" and "[,]" might
                  >also have to be permissible, and maybe even "{:}" for an
                  >empty dict.
                  The notion of a set literal was rejected in PEP 218,
                  http://www.python.org/dev/peps/pep-0218/ . One of the reasons for the
                  rejection was that the small benefit of a literal notion was more than
                  offset by the attendant need for syntactical atrocities like those
                  listed above.


                  Raymond

                  Comment

                  • bearophileHUGS@lycos.com

                    #10
                    Re: builtin set literal

                    Raymond Hettinger:
                    One of the reasons for the
                    rejection was that the small benefit of a literal notion was more than
                    offset by the attendant need for syntactical atrocities like those
                    listed above.
                    {:} for empty dict and {} for empty set don't look too much atrocious
                    to me.


                    Note: the language Fortress, that in graphic modality uses unicode for
                    its sources, has many collection literals (6 or more, you can see 3 of
                    them at page 21):


                    Bye,
                    bearophile

                    Comment

                    • =?ISO-8859-1?Q?Sch=FCle_Daniel?=

                      #11
                      Re: builtin set literal

                      {:} for empty dict and {} for empty set don't look too much atrocious
                      to me.
                      this looks consistent to me

                      Comment

                      • Steven Bethard

                        #12
                        Re: builtin set literal

                        Schüle Daniel wrote:
                        >{:} for empty dict and {} for empty set don't look too much atrocious
                        >to me.
                        >
                        this looks consistent to me
                        Yes, a lot of people liked this approach, but it was rejected due to
                        gratuitous breakage. While Python 3.0 is not afraid to break backwards
                        compatibility, it tries to do so only when there's a very substantial
                        advantage. I guess enough people felt that having a shortcut for set()
                        was less important than keeping the current spelling of dict() the same.

                        STeVe

                        Comment

                        • Paul Rubin

                          #13
                          Re: builtin set literal

                          Steven Bethard <steven.bethard @gmail.comwrite s:
                          Yes, a lot of people liked this approach, but it was rejected due to
                          gratuitous breakage. While Python 3.0 is not afraid to break backwards
                          compatibility, it tries to do so only when there's a very substantial
                          advantage. I guess enough people felt that having a shortcut for set()
                          was less important than keeping the current spelling of dict() the same.
                          There's even a sentiment in some pythonistas to get rid of the [] and {}
                          notations for lists and dicts, using list((1,2,3)) and dict((1,2),(3,4 ))
                          for [1,2,3] and {1:2, 3:4} respectively.

                          Comment

                          • Paul Rubin

                            #14
                            Re: builtin set literal

                            Paul Rubin <http://phr.cx@NOSPAM.i nvalidwrites:
                            notations for lists and dicts, using list((1,2,3)) and dict((1,2),(3,4 ))
                            for [1,2,3] and {1:2, 3:4} respectively.
                            Actually that would be dict(((1,2), (3,4))), of course.

                            Comment

                            • Hendrik van Rooyen

                              #15
                              Re: builtin set literal

                              "Paul Rubin" <http://phr.cx@NOSPAM.i nvalidwrote:


                              Steven Bethard <steven.bethard @gmail.comwrite s:
                              Yes, a lot of people liked this approach, but it was rejected due to
                              gratuitous breakage. While Python 3.0 is not afraid to break backwards
                              compatibility, it tries to do so only when there's a very substantial
                              advantage. I guess enough people felt that having a shortcut for set()
                              was less important than keeping the current spelling of dict() the same.
                              >
                              There's even a sentiment in some pythonistas to get rid of the [] and {}
                              notations for lists and dicts, using list((1,2,3)) and dict((1,2),(3,4 ))
                              for [1,2,3] and {1:2, 3:4} respectively.
                              YUK!

                              Moving in the wrong direction to bracketmania!

                              If you are going to use only one kind of brackets, use [] - on most keyboards,
                              you don't have to press the shift key - think of the numberless hours of total
                              time
                              saved by this simple reform...

                              It will also give Python a very distinctive "look" - unlike any other language.

                              - Hendrik

                              Comment

                              Working...