Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python dictionnary
#3
True and False are actually subclasses of integers, with True equal to 1 and False equal to 0. You can test this by adding them to normal integers. So when Python gets to 'True: False', it sets the value of 1 to False, overriding the previous value of 'apple'.

To be more specific, if hash(x) == hash(y) and x == y, then dictionaries will treat x and y as the same key. That's what is going on here.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
python dictionnary - by Omar_Yatim - Dec-07-2019, 07:50 PM
RE: python dictionnary - by michael1789 - Dec-07-2019, 07:54 PM
RE: python dictionnary - by ichabod801 - Dec-07-2019, 07:56 PM
RE: python dictionnary - by scidam - Dec-08-2019, 05:12 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Dictionnary indexing error Ander 6 1,973 Sep-10-2021, 12:22 PM
Last Post: Ander
  Dictionnary brackets issue Reldaing 1 1,880 Nov-10-2019, 11:54 PM
Last Post: ichabod801
  Access to the elements of a dictionnary Reims 1 1,669 Oct-02-2019, 12:48 PM
Last Post: SheeppOSU
  from Json Time Serie file to python dictionnary Reims 1 2,081 Sep-11-2019, 08:17 AM
Last Post: DeaD_EyE
  convert a json file to a python dictionnary of array Reims 2 2,295 Sep-10-2019, 01:08 PM
Last Post: Reims
  dictionnary lateublegende 1 2,485 Apr-29-2019, 09:10 PM
Last Post: Yoriz
  Why do we need setdefault() method for dictionnary? DJ_Qu 3 2,743 Apr-21-2019, 11:00 AM
Last Post: Gribouillis
  Json dictionnary on Redis katsu707 1 2,486 Dec-04-2018, 11:59 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020