Solved

Insert a dictionary into a dictionary?

Posted on 2015-02-09
4
113 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 37

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 37

Expert Comment

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

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# Error - Add Failed 12 89
Apps blocked by Java 9 81
Plain Text Editor for iPad 6 77
Looking for a network enabled locker remotely controlled like Amazon locker 2 79
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
The viewer will learn how to dynamically set the form action using jQuery.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

822 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