Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 167
  • Last Modified:

Insert a dictionary into a dictionary?

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
DrDamnit
Asked:
DrDamnit
  • 2
  • 2
1 Solution
 
Gerwin Jansen, EE MVETopic Advisor Commented:
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
 
DrDamnitAuthor Commented:
Error is:
dict() error
Code is:
dict() 'ing around
0
 
DrDamnitAuthor Commented:
Figured it out. I was trying to pass a dict as a key instead of a value.

For future PAQers...

super dict()
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
OK, thanks for feedback ;)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now