473,386 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

what is this error?

shahram555
Expand|Select|Wrap|Line Numbers
  1. c={'a':1,'b':2}
  2. c.has_key('a')
Traceback (most recent call last):
File "<pyshell#32>", line 1, in <module>
c.has_key('a')
AttributeError: 'dict' object has no attribute 'has_key'


Why does this fail?
Aug 13 '14 #1

✓ answered by dwblas

What version of Python are you useing? has_key() was removed in Python3.x I think. Use "in",

Expand|Select|Wrap|Line Numbers
  1. c={'a':1,'b':2}
  2. print 'a' in c 

2 1285
bvdet
2,851 Expert Mod 2GB
Expand|Select|Wrap|Line Numbers
  1. >>> c={'a':1,'b':2}
  2. >>> c.has_key('a')
  3. True
I can't explain it. 'has_key' is a read-only attribute of a dict object.
Aug 13 '14 #2
dwblas
626 Expert 512MB
What version of Python are you useing? has_key() was removed in Python3.x I think. Use "in",

Expand|Select|Wrap|Line Numbers
  1. c={'a':1,'b':2}
  2. print 'a' in c 
Aug 13 '14 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: paul dallaire | last post by:
HI! I have a readme that gives the following statement. Requirements PHP3 or PHP4: PHP also needs to be compiled with MySQL support; MySQL (tested with 3.21.x, 3.22.x, 3.23.x and 4.0.x); A...
29
by: asj | last post by:
Can you guess what this is? http://www.blueboard.com/phone/apache_sept_2003.gif It's a history of the IIs "Titanic", which is being slowly and painfully sunk by the open source Apache web...
12
by: craig | last post by:
Quick question for the experts... Whenever I set the Image property of a PictureBox on one of my windows forms to a PNG graphic file on my hard drive, I get the following runtime error when I...
4
by: mistral | last post by:
Can anyone help to identify what this encryption used in this script? <html> <body> <script type="text/javascript" language="JavaScript"> function decrypt_p(x){ var l=x.length, b=1024,...
3
by: manjuks | last post by:
HI All, Can any one please let me know what this for loop is trying to do for V in ${MYVERSION:-"$VERSION"} what :- stands for? I dont understand this condition, Can any one help me please?...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.