Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A dictionary key acceptsint,float,complex,bool and a tuple #134992

Closed as not planned
Labels
type-bugAn unexpected behavior, bug, or error
@hyperkai

Description

@hyperkai

Bug report

Bug description:

I don't know if it's bug or not. A dictionary key acceptsint,float,complex,bool and a tuple as shown below:

v= {2:3,2.3:4.5,2.3+4.5j:6.7+8.9j,True:False, (2,3):(4,5)}print(v[2],v[2.3],v[2.3+4.5j],v[True],v[(2,3)])# 3 4.5 (6.7+8.9j) False (4, 5)

In addition, a dictionary key doesn't accept a list, set and dictionary as shown below:

v= {[2,3]:[4,5]}print(v[[2,3]])# TypeError: unhashable type: 'list'
v= {{2,3}:{4,5}}print(v[{2,3}])# TypeError: unhashable type: 'set'
v= {{'a':'b'}:{'c':'d'}}print(v[{'a':'b'}])# TypeError: unhashable type: 'dict'

CPython versions tested on:

3.12

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp