Re: hash()

Discussion in 'Python' started by Tim Peters, Dec 6, 2005.

  1. Tim Peters

    Tim Peters Guest

    [John Marshall]
    >>> For strings of > 1 character, what are the chances
    >>> that hash(st) and hash(st[::-1]) would return the
    >>> same value?


    [Tim Peters]
    >> First, if `st` is a string, `st[::-1]` is a list. Do you really mean
    >> to compare string hashes with list hashes here? I'm going to assume
    >> not.


    [Jeff Epler]
    > It is?
    >
    > >>> st = "french frogs"
    > >>> st[::-1]

    > 'sgorf hcnerf'
    >
    > (Python 2.3)


    Indeed that's right. Python 2.4+ also. My apologies! Good thing it
    doesn't matter to the rest of the exposition ;-)
     
    Tim Peters, Dec 6, 2005
    #1
    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. Red Orchid
    Replies:
    3
    Views:
    1,092
  2. Pieter Claassen
    Replies:
    1
    Views:
    1,151
    CBFalconer
    Aug 4, 2004
  3. Bo Peng
    Replies:
    4
    Views:
    817
  4. rp
    Replies:
    1
    Views:
    594
    red floyd
    Nov 10, 2011
  5. Srijayanth Sridhar
    Replies:
    19
    Views:
    676
    David A. Black
    Jul 2, 2008
Loading...

Share This Page