Solved

Insert a dictionary into a dictionary?

Posted on 2015-02-09
4
117 Views
Last Modified: 2015-02-10
I am working on building an auto-complete for readline. What I have works, but it's static.

I want it to be able to prompt me based on file contents.

Although I knew it wouldn't work, here's what I tried:
dict in dict
What I want is the output of this function to be part of the dictionary at the place called out with the arrow above:
quit dicting around
For reference, this is how the readline completer is coded:
I'll show you my dict() if you show me yours.
0
Comment
Question by:DrDamnit
  • 2
  • 2
4 Comments
 
LVL 38

Accepted Solution

by:
Gerwin Jansen, EE MVE earned 500 total points
ID: 40599530
What is the error you get and what it the output you get from loadSites()?

This is working:

>>> def loadS():
...   return {'d':None, 'e':None}
...
>>> loadS()
{'e': None, 'd': None}
>>> LOGIC = {
...   'cm': {},
...   'show': {
...     'sites':loadS(),
...     'config':None
...   }
... }
>>> LOGIC
{'cm': {}, 'show': {'config': None, 'sites': {'e': None, 'd': None}}}
>>>

Open in new window

0
 
LVL 32

Author Comment

by:DrDamnit
ID: 40600588
Error is:
dict() error
Code is:
dict() 'ing around
0
 
LVL 32

Author Comment

by:DrDamnit
ID: 40600598
Figured it out. I was trying to pass a dict as a key instead of a value.

For future PAQers...

super dict()
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40601648
OK, thanks for feedback ;)
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to demonstrate how we can use conditional statements using Python.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question