• Home
  • Most Popular
  • Submit
  • About Us
  • Contact Us

Softpile

Free Downloads

Categories
  • Home
  • Most Popular
  • Communications
  • Desktop
  • Games & Entertainment
  • Graphic Apps
  • Network & Internet
  • Security & Privacy
  • System Utilities
Alternative to itextsharp 2022.11.10347
IronPDF offers an itextsharp alternative for HTML to PDF conversion with C# code examples, documentation, and ...
VShell Server for Linux and Mac 4.8
VShell is a versatile and secure file transfer server that supports multiple protocols and is compatible ...
PDF Studio PDF Editor for Linux 2022
PDF Studio is a cost-effective PDF editor that delivers full compatibility with the PDF Standard. It's ...
VQ Probe for Linux 1.5
VQ Probe is a comprehensive software tool that enables objective and subjective video quality analysis. The ...
Resilient Server 2.3
This Debian GNU/Linux (Buster) based software has a customized partitioning scheme that enhances robustness against filesystem ...
Valentina Studio for Linux 9.6
Valentina Studio is a cross-platform GUI manager for Mac, Windows, and Linux. It allows users to ...
VPN Lifeguard for Linux 1.0.58
The software monitors VPN connection and automatically terminates apps during connection loss, re-establishes the connection and ...
G_Viewer 0.84
G_Viewer is a Linux software that serves as both a file system and photo/image viewer. It ...
Checksome File Hash Tool for Linux 1.1
This software allows for the generation and verification of file hashes. It is a quick and ...
KeyWrangler Password Manager for Linux 1.2
A password management software that is secure, offline and extensible. It offers military-grade encryption to protect ...
Home Linux nested_dict Download

nested_dict

August 17, 2009
This software provides a defaultdict extension that works for dictionaries containing multiple levels of nesting.
Version 1.0.8
License Proprietary License
Platform Linux
Supported Languages English
Homepage code.google.com
Developed by Leo Goodstadt
Nested_dict is a powerful Python module designed to extend collections.defaultdict to create nested dictionaries of multiple levels on the fly. With this module, you can easily create nested dictionaries, even if they have not yet been declared. Auto-vivification, a process also known as "auto-creation," makes this possible. This feature can be a huge time-saver for those who regularly work with complex data structures.

Creating a nested_dict is straightforward. Once you have imported the module, you can declare the dictionary and its levels as follows:

nd = nested_dict()
nd["a"]["b"]["c"] = 311
nd["d"]["e"] = 311

Each time you access a nested level, it is created automatically. In the above example, accessing nd["a"]["b"]["c"] for the first time creates the dictionary {"a": {"b": {"c": 311}}}.

Nested_dict also extends collections.defaultdict beyond simple dictionary creation. You can create dictionaries of lists, sets, or other collections with a specified level of nesting using slightly different syntax.

First, you can use the old-fashioned way of creating a dictionary with ugly syntax:

d = dict()
d.setdefault("1st group", []).append(3)
d.setdefault("2nd group", []).append(5)
d.setdefault("2nd group", []).append(8)
d.setdefault("1st group", []).append(4)
d.setdefault("2nd group", []).append(5)

Alternatively, you can use the collections.defaultdict module for easy list creation:

from collections import defaultdict
dd = defaultdict(list)
dd["1st group"].append(3)
dd["2nd group"].append(5)
dd["2nd group"].append(8)
dd["1st group"].append(4)
dd["2nd group"].append(5)

Finally, you can create nested dictionaries that automatically create lists or other collections when required:

from nested_dict import nested_dict
nd = nested_dict(2, list)
nd["1st group"]["subset a"].append(3)
nd["2nd group"]["subset a"].append(5)
nd["2nd group"]["subset b"].append(8)
nd["1st group"]["subset a"].append(4)
nd["2nd group"]["subset b"].append(5)

By specifying two levels of nesting and a list object, we create nd as a nested dictionary of lists. Accessing the nested levels automatically creates the required lists. The resulting dictionary, as printed with print(nd), is:

{'1st group': {'subset a': [3, 4]}, '2nd group': {'subset b': [8, 5], 'subset a': [5]}}

Nested_dict also supports other collections, such as sets, with the same ease-of-use.

Other features of nested_dict include auto-vivification of nested dictionaries and the ability to specify a collection type at initialization.

In conclusion, nested_dict is a valuable addition to any Python developer's toolbox, providing powerful tools for the creation and manipulation of complex data structures.
What's New

Version 1.0.8: N/A

Free Download 12K
321
  • Share on:

Most Popular

  1. Quicksilver Forums 1.4.2
    157
  2. Dvgrab 3.4
    94
  3. DynVPN 1.0
    83
  4. CherryTV 0.1
    81
  5. SlideMap 1.2.2
    76
  6. porm r2
    72
  7. Clewarecontrol 0.8
    71
  8. Hills 2.0
    71
  9. fuseftp 0.8
    70
  10. Java Games 1.0
    70

Related Downloads

DC#
DC# is a user-friendly software that facilitates file sharing.
phpminiadmin
Phpminiadmin is a lightweight and straightforward software that provides quick and easy ...
TVSpectre
TVSpectre is a software that retrieves TV program information from tvmovie.de.
Debian Live Manual
Access all Debian Live project documentation from one point with ease.
Gtk2Hack
Gtk2Hack is a graphical user interface for nethack, a popular rogue-like RPG ...
gtrainer
gtrainer simplifies sports training management with an easy-to-use interface. It's built to ...
Nasal
Nasal is a small and complete embedded scripting language with a simple ...
Rose::DBx::Bouquet
This software utilizes a database schema to automatically produce source code based ...
MySQL Backup for lazy sysadmins
Automate your MySQL database backups with mysqlblasy, a Perl script for the ...
Backup-DVD
Backup-DVD is a straightforward software for creating a complete system backup onto ...
Copyright © 1999-2025 Softpile Free Downloads
  • Most Popular
  • Submit
  • About Us
  • Contact Us
  • Privacy Policy
  • Disclaimer
  • Terms of Use

Can we use your data to tailor ads for you?

Our partners will collect data and use cookies for ad personalization and measurement.

By choosing "I agree", closing this pop-up or clicking on any element on the page, you agree to the use of cookies to help us provide you with a better user experience.

Learn how Softpile and our partners collect and use data.

You can change your choice at any time in our privacy center.

Cookie Settings

Our website stores four types of cookies. At any time you can choose which cookies you accept and which you refuse. You can read more about what cookies are and what types of cookies we store in our Cookie Policy.

are necessary for technical reasons. Without them, this website may not function properly.

are necessary for specific functionality on the website. Without them, some features may be disabled.

allow us to analyse website use and to improve the visitor's experience.

allow us to personalise your experience and to send you relevant content and offers, on this website and other websites.