Python Forum
Error 'object has no attribute' when iterating thru a dictionary
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error 'object has no attribute' when iterating thru a dictionary
#8
Wait a minute.
If I do:
#Interface variable match:
match='0/7'

Then I execute it and I get a match. So it seems the issue is that [] character still on the interface "match" variable. But when I converted it to string, I thought it would go away. Do you agree I need to replace the [] with no characters here?

Original data from appliance, dictionary:defaultdict(<class 'list'>, {'PSE2': ['0/7/CPU0', '1/0/CPU0', '1/2/CPU0']})
Printing original interface value=['0/5']
type of values v <class 'str'> ['0/7/CPU0', '1/0/CPU0', '1/2/CPU0'] and type of interface:<class 'str'> ['0/5']
Now printing manually assigned value to match interface: 0/7
**** FINALLY FOUND IT ****
Original data from appliance, dictionary:defaultdict(<class 'list'>, {'PSE2': ['0/7/CPU0', '1/0/CPU0', '1/2/CPU0']})
Printing original interface value=['0/7']
type of values v <class 'str'> ['0/7/CPU0', '1/0/CPU0', '1/2/CPU0'] and type of interface:<class 'str'> ['0/7']
Now printing manually assigned value to match interface: 0/7
**** FINALLY FOUND IT ****
exit...

I see we replied at the same time.
Sure I understand the problem now.
I no longer convert the dictionary values 'v' into a string.

Then it is obvious the interface value 'match' is still showing:
Printing original interface value=['0/7']

So can you tell me again your thoughts if it is needed to write a function to replace [] with no character at all?
Reply


Messages In This Thread
RE: Error 'object has no attribute' when iterating thru a dictionary - by mrapple2020 - Apr-07-2019, 11:31 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Error: audioio has no attribute 'AudioOut' netwrok 3 757 Oct-22-2023, 05:53 PM
Last Post: netwrok
  AttributeError: '_tkinter.tkapp' object has no attribute 'username' Konstantin23 4 2,070 Aug-04-2023, 12:41 PM
Last Post: Konstantin23
  Need help with 'str' object is not callable error. Fare 4 976 Jul-23-2023, 02:25 PM
Last Post: Fare
  Python: AttributeError: 'PageObject' object has no attribute 'extract_images' Melcu54 2 4,373 Jun-18-2023, 07:47 PM
Last Post: Melcu54
  Object attribute behavior different in 2 scripts db042190 1 871 Jun-14-2023, 12:37 PM
Last Post: deanhystad
  cx_oracle Error - AttributeError: 'function' object has no attribute 'cursor' birajdarmm 1 2,678 Apr-15-2023, 05:17 PM
Last Post: deanhystad
  Pandas AttributeError: 'DataFrame' object has no attribute 'concat' Sameer33 5 6,138 Feb-17-2023, 06:01 PM
Last Post: Sameer33
  WebDriver' object has no attribute 'find_element_by_css_selector rickadams 3 6,225 Sep-19-2022, 06:11 PM
Last Post: Larz60+
  'dict_items' object has no attribute 'sort' Calli 6 4,813 Jul-29-2022, 09:19 PM
Last Post: Gribouillis
  AttributeError: 'numpy.ndarray' object has no attribute 'load' hobbyist 8 7,421 Jul-06-2022, 10:55 AM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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