Skip to main content

Python package for flatting of list, tuple or dictionary.

Project description

Flatway

Easily flat list, tuple or dictionary in your python project.

How to use?

  • install package using pip install flatway
  • import package in your project.
from flatway.flatten import flatten, flattenDict

myList = [1,2,3,[4,5,6,[7,8,9,[10,11]]]]
depth = 3 
# default to 1

flatList = flatten(myList , depth)
# [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]

myTuple = (1,2,3,(4,5,6,(7,8,9,(10,11))))
flatTuple = flatten(myTuple, depth)
# (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)

person = {"name" : "Paiman", "age" : 12, "info" : {"loveFootball" : True}}
flatPerson = flattenDict(person)
# {"name": "Paiman", "age": 12 , "loveFootball": true}

Run the tests

pytest src/tests/test_flatten.py

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

flatway-2.0.0.tar.gz (3.3 kB view details)

Uploaded Source

File details

Details for the file flatway-2.0.0.tar.gz.

File metadata

  • Download URL: flatway-2.0.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for flatway-2.0.0.tar.gz
Algorithm Hash digest
SHA256 34e1c086a24859f9106801327442cabcdb26378edb39e45d8ab308c309ffb1bc
MD5 769602b3e575a6ee7a695d49ac1ad3ea
BLAKE2b-256 f273f7f7a9a5cd5c73f649f7c5472176a99db21cb99b1ef32bb318cf673e1e81

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