Skip to main content

Convert a dict into an object to access items faster.

Project description

Dictoat

Dictoat is a Python utility designed to simplify accessing data stored in dictionaries. It converts dictionaries into Python objects, allowing for more intuitive access to data via attributes instead of dictionary keys. This is ideal for projects where readability and ease of access to complex data structures are essential.

Installation

You can easily install Dictoat using pip:

pip install dictoat

or via git:

git clone https://github.com/niCodeLine/dictoat.git

or just copy-paste it into your code.

Usage

To use Dictoat, simply import the Dictoat class in your Python project and pass a dictionary as an argument. For example:

from dictoat import Dictoat

# Example of using Dictoat
apple_dict = {"flavor": "sweet", "colors": ["red", "green"],"dimentions": {"weigh": 185, "radius": 5}}
apple = Dictoat(apple_dict)

# Accessing the data
print(apple.flavor_)
print(apple.dimentions_.radius_)
print(apple.colors_)

The output would show:

sweet
5
["red", "green"]

Or a more complete example:

from dictoat import Dictoat

pokedex_dict = {
    "total_pokemons": 2,
    "region": "Kanto",
    "Pokemons": {
        "Pikachu": {
            "type": "Electric",
            "abilities": ["Static", "Lightning Rod"],
            "stats": {
                "hp": 35,
                "attack": 55,
                "defense": 40
            }
        },
        "Squirtle": {
            "type": "Water",
            "abilities": ["Torrent", "Rain Dish"],
            "stats": {
                "hp": 44,
                "attack": 48,
                "defense": 65
            },
            "evolutions": ["Wartortle", "Blastoise"]
        }
    }
}

pokedex = Dictoat(pokedex_dict)

# Accessing the data
print("Total Pokémon in Pokedex:", pokedex.total_pokemons_)
print("Pokedex Region:", pokedex.region_)

print("Pikachu Type:", pokedex.Pokemons_.Pikachu_.type_)
print("Pikachu Abilities:", pokedex.Pokemons_.Pikachu_.abilities_)
print("Pikachu HP:", pokedex.Pokemons_.Pikachu_.stats_.hp_)

print("Squirtle Type:", pokedex.Pokemons_.Squirtle_.type_)
print("Squirtle Abilities:", pokedex.Pokemons_.Squirtle_.abilities_)
print("Squirtle Defense:", pokedex.Pokemons_.Squirtle_.stats_.defense_)
print("Squirtle Evolutions:", pokedex.Pokemons_.Squirtle_.evolutions_)

With its output being:

Total Pokémon in Pokedex: 2
Pokedex Region: Kanto

Pikachu Type: Electric
Pikachu Abilities: ['Static', 'Lightning Rod']
Pikachu HP: 35

Squirtle Type: Water
Squirtle Abilities: ['Torrent', 'Rain Dish']
Squirtle Defense: 65
Squirtle Evolutions: ['Wartortle', 'Blastoise']

Features

  • Simple Conversion: Converts any dictionary into an object for easier access.
  • Deep Nesting Support: Supports nested dictionaries, creating sub-objects for each level.

Contributions

Contributions are welcome! If you have improvements or fixes, please send a pull request or open an issue in the GitHub repository.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Contact

Nico Spok - nicospok@hotmail.com GitHub: niCodeLine

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dictoat-1.0.1.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dictoat-1.0.1-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file dictoat-1.0.1.tar.gz.

File metadata

  • Download URL: dictoat-1.0.1.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for dictoat-1.0.1.tar.gz
Algorithm Hash digest
SHA256 eda46485e6cf1a433fc8fcdd097e006d311deb745bec2ab2496b87893ad92ebb
MD5 7eb0b5e5540bc61a6a15b38a2fd1617d
BLAKE2b-256 b4ca881a39b5b32a31bddee3f34a562b375810591f44dba45e7f2c07a7fe154b

See more details on using hashes here.

File details

Details for the file dictoat-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: dictoat-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for dictoat-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9ba7b7d84d7c3ff598c2ef205c20bae0bef56b4de60d797e01982b9ba4609337
MD5 dd14a61e67bf1179529bc0860fc63bba
BLAKE2b-256 53d8a1f2b3e8087ee2322c4a6c94e0f2aba36170f4529209f1accef4bb3c5fe3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page