question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError: 'dict' object has no attribute 'has_key'

See original GitHub issue

I use anaconda with python3.5 and tensorflow 1.2 in win10. Running the example codes: python main.py --dataset ptb and python main.py --dataset ptb --forward_only_True both give the same error message.

Traceback shows there may be something wrong with: if not word2idx.has_key(word): in batch_loader.py (line 144)

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
405560984commented, Mar 18, 2019

you must use “if key in cdist:”, cdist is your data name

0reactions
hrandiaccommented, Dec 30, 2017

I get an AttributeError: ‘dict’ object has no attribute ‘has_key’ in python 2.7

Read more comments on GitHub >

github_iconTop Results From Across the Web

'dict' object has no attribute 'has_key' - python - Stack Overflow
has_key was removed in Python 3. From the documentation: Removed dict.has_key() – use the in operator instead. Here's an example:
Read more >
Attributeerror: dict object has no attribute has_key ( Solution )
Attributeerror: dict object has no attribute has_key error occurs because has_key() function is deprecated syntax in python 3. But do not worry, ...
Read more >
Attributeerror: dict object has no attribute has_key ( Solved )
The solution of the attributeerror: dict object has no attribute has_key is very simple. You have to use the latest functions for checking...
Read more >
'dict' object has no attribute 'has_key' - Codersarts
'dict' object has no attribute 'has_key'. has_key() is method defined in python 2 so not available in Python 3.
Read more >
Dict' Object Has No Attribute 'Key' in Python | Codeigo
Dict ' Object Has No Attribute 'Key' in Python ... The Python error we are discussing here is of AttributeError class. AttributeError generally ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found