operator.isMappingType

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Raymond Hettinger

    operator.isMappingType

    Since the advent of extended slicing, operator.isMapp ingType() returns a
    misleading result.
    [color=blue][color=green][color=darkred]
    >>> map(operator.is MappingType, ([], (), {}, '', u''))[/color][/color][/color]
    [True, True, True, True, True]


    I recommend removing it from the operator module.


    Raymond Hettinger


  • John Roth

    #2
    Re: operator.isMapp ingType


    "Raymond Hettinger" <vze4rx4y@veriz on.net> wrote in message
    news:vgYob.4644 7$4O1.17443@nwr dny01.gnilink.n et...[color=blue]
    > Since the advent of extended slicing, operator.isMapp ingType() returns a
    > misleading result.
    >[color=green][color=darkred]
    > >>> map(operator.is MappingType, ([], (), {}, '', u''))[/color][/color]
    > [True, True, True, True, True]
    >
    >
    > I recommend removing it from the operator module.[/color]

    I get the following on 2.2.3:
    [color=blue][color=green][color=darkred]
    >>> map (operator.isMap pingType,([], {}, (), ", u"))[/color][/color][/color]
    [0, 1, 0, 0]

    Where did the fifth True come from? That's really odd!

    How much code would removing it break, versus
    changing the test so it looked for one or more of the
    methods that's unique to maps, and not to other
    kinds of sequences? Granted, testing for something
    other than a magic method would slow it down, but
    that should be better than either leaving it broken,
    or breaking otherwise innocent code.

    John Roth


    [color=blue]
    >
    >
    > Raymond Hettinger
    >
    >[/color]


    Comment

    • Peter Hansen

      #3
      Re: operator.isMapp ingType

      John Roth wrote:[color=blue]
      >
      > "Raymond Hettinger" <vze4rx4y@veriz on.net> wrote in message
      > news:vgYob.4644 7$4O1.17443@nwr dny01.gnilink.n et...[color=green]
      > > Since the advent of extended slicing, operator.isMapp ingType() returns a
      > > misleading result.
      > >[color=darkred]
      > > >>> map(operator.is MappingType, ([], (), {}, '', u''))[/color]
      > > [True, True, True, True, True]
      > >
      > >
      > > I recommend removing it from the operator module.[/color]
      >
      > I get the following on 2.2.3:
      >[color=green][color=darkred]
      > >>> map (operator.isMap pingType,([], {}, (), ", u"))[/color][/color]
      > [0, 1, 0, 0]
      >
      > Where did the fifth True come from? That's really odd![/color]

      Raymond used pairs of single quotes, while you used only
      individual double-quotes surrounding a string containing
      a comma, a space, and the letter u. His had an empty
      string and an empty unicode string...

      -Peter

      Comment

      • John Roth

        #4
        Re: operator.isMapp ingType


        "Peter Hansen" <peter@engcorp. com> wrote in message
        news:3FA465CC.8 F11293D@engcorp .com...[color=blue]
        > John Roth wrote:[color=green]
        > >
        > > "Raymond Hettinger" <vze4rx4y@veriz on.net> wrote in message
        > > news:vgYob.4644 7$4O1.17443@nwr dny01.gnilink.n et...[color=darkred]
        > > > Since the advent of extended slicing, operator.isMapp ingType() returns[/color][/color][/color]
        a[color=blue][color=green][color=darkred]
        > > > misleading result.
        > > >
        > > > >>> map(operator.is MappingType, ([], (), {}, '', u''))
        > > > [True, True, True, True, True]
        > > >
        > > >
        > > > I recommend removing it from the operator module.[/color]
        > >
        > > I get the following on 2.2.3:
        > >[color=darkred]
        > > >>> map (operator.isMap pingType,([], {}, (), ", u"))[/color]
        > > [0, 1, 0, 0]
        > >
        > > Where did the fifth True come from? That's really odd![/color]
        >
        > Raymond used pairs of single quotes, while you used only
        > individual double-quotes surrounding a string containing
        > a comma, a space, and the letter u. His had an empty
        > string and an empty unicode string...[/color]

        I see. That did look odd...

        John Roth[color=blue]
        >
        > -Peter[/color]


        Comment

        Working...