November 2, 2017 at 8:58 pm
Comments posted to this topic are about the item Python Dictionaries
November 3, 2017 at 12:05 am
Nice one, thanks Steve
Definitely time to dust off those old Python skills
____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
November 3, 2017 at 2:05 am
Hmm good question Steve, time to learn a bit of Python me thinks.
...
November 3, 2017 at 6:13 am
Easy one for me. Here is something cool to think about how list and dicts can work together.
# Two dictionaries with two sets of rows and columns
dictA = {'CustomerID': [1, 2, 3, 4, 5], 'FirstName': ['John', 'Joe', 'Sarah', 'Jane', 'Sam']}
dictB = {'CustomerID': [1, 2, 3, 4, 5], 'FirstName': ['Sue', 'Aiden', 'Stephanie', 'Steve', 'Faye']}
# List of my dictionaries
myList = [dictA, dictB]
# Being our dictionaries contain the same field names, we can use a list to help us keep track of each dict and iterate over them.
# We can then use a forloop to iterate and list out each list within each dict.
for records in myList:
for customers in records['FirstName']:
print customers
Course, you could just combine the dicts too. But it's interesting to think about how they can be separate and reference each other too.
November 3, 2017 at 11:16 am
I've never used python, so I guessed. I guessed poorly.
November 6, 2017 at 7:56 am
Ed Wagner - Friday, November 3, 2017 11:16 AMI've never used python, so I guessed. I guessed poorly.
I've never used it either, but I have read odd bits of python code here and there (helping someone find his silly errors) and had a vague memory of hash tables being called dictionaries and using square brackets for keys.
My son tells me I should learn the language, but I'm not convinced.
Tom
July 27, 2018 at 3:53 pm
Nice question. Thanks Steve.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply