Skip to main content

Use methods and method chaining on lists of objects.

Project description

ObjectList

Use methods and method chaining on lists of objects. Also allowing clean syntax for parallel processing.

Examples

As an example we define an ObjectList of Path objects.

from objectlist import ObjectList

from pathlib import Path
path_list = [Path('foo/a'), Path('foo/bar/b'), Path('foo/bar/c')]
path_objectlist = ObjectList(path_list)

Getting object attributes and properties

If we would like to get the parents of all paths

[WindowsPath('foo'), WindowsPath('foo/bar'), WindowsPath('foo/bar')]

then using a normal list it is necessary to use a loop:

[p.parent for p in path_list]

but using an ObjectList this can be done by

path_objectlist.parent

ObjectLists can be easily converted to strings:

path_objectlist.parent.str
['foo', 'foo\\bar', 'foo\\bar']

Using object methods and passing arguments

Object methods can also be used

path_objectlist.with_suffix('.txt')
[WindowsPath('foo/a.txt'), WindowsPath('foo/bar/b.txt'), WindowsPath('foo/bar/c.txt')]

Using parallel processing

Parallel processing can be activated on existing ObjectLists by using .parallel

path_objectlist.parallel.with_suffix('.txt')

Alternatively parallel processing can be activated when the ObjectList is defined:

path_objectlist = ObjectList(path_list, 
                             use_parallel_processing=True, 
                             number_of_cores=None,
                             parallel_processing_kwargs=dict(verbose=0), 
                             return_none_if_all_none=True)

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

objectlist-1.0.2.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

objectlist-1.0.2-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file objectlist-1.0.2.tar.gz.

File metadata

  • Download URL: objectlist-1.0.2.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for objectlist-1.0.2.tar.gz
Algorithm Hash digest
SHA256 8b3b54c28dc5deafec5e5cac4365aa0141adedd0d63b07ca6f69d5aab3547131
MD5 b797c37ec039499dd0168f093e1d6f18
BLAKE2b-256 eca092b191513ff703b0ce661d0776dc97324dfafeac2d3de2943252126f6330

See more details on using hashes here.

File details

Details for the file objectlist-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: objectlist-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 17.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for objectlist-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f6e4cd31810785b233fe13372a14293b379dcaa05e7851196050d6d52f786f05
MD5 548ab93bf90aa7f739aceb4f2387e657
BLAKE2b-256 add767a38f79e8912703ca78e0669c6b93893b742843a30fa6bc61c7e1b039ab

See more details on using hashes here.

Supported by

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