Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Insert a dictionary into a dictionary?

Posted on 2015-02-09
4
Medium Priority
?
135 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 38

Accepted Solution

by:
Gerwin Jansen, EE MVE earned 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Simple Linear Regression

721 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