objectlist


Nameobjectlist JSON
Version 1.0.2 PyPI version JSON
download
home_page
SummaryUse methods and method chaining on lists of objects.
upload_time2024-02-13 15:46:49
maintainer
docs_urlNone
author
requires_python>=3.9
license
keywords object list method chaining
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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.

```python
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 

```plaintext
[WindowsPath('foo'), WindowsPath('foo/bar'), WindowsPath('foo/bar')]
```
then using a normal list it is necessary to use a loop:

```python
[p.parent for p in path_list]
```

but using an ObjectList this can be done by
```python
path_objectlist.parent
```

ObjectLists can be easily converted to strings:
```python
path_objectlist.parent.str
```

```plaintext
['foo', 'foo\\bar', 'foo\\bar']
```

### Using object methods and passing arguments
Object methods can also be used

```python
path_objectlist.with_suffix('.txt')
```
```plaintext
[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 

```python
path_objectlist.parallel.with_suffix('.txt')
```

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

```python
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)
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "objectlist",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "",
    "keywords": "object,list,method,chaining",
    "author": "",
    "author_email": "Ivo Severins <i.w.h.severins@tudelft.nl>",
    "download_url": "https://files.pythonhosted.org/packages/ec/a0/92b191513ff703b0ce661d0776dc97324dfafeac2d3de2943252126f6330/objectlist-1.0.2.tar.gz",
    "platform": null,
    "description": "# ObjectList\r\n\r\nUse methods and method chaining on lists of objects.\r\nAlso allowing clean syntax for parallel processing.\r\n\r\n\r\n## Examples\r\n\r\nAs an example we define an ObjectList of Path objects.\r\n\r\n```python\r\nfrom objectlist import ObjectList\r\n\r\nfrom pathlib import Path\r\npath_list = [Path('foo/a'), Path('foo/bar/b'), Path('foo/bar/c')]\r\npath_objectlist = ObjectList(path_list)\r\n```\r\n\r\n### Getting object attributes and properties\r\nIf we would like to get the parents of all paths \r\n\r\n```plaintext\r\n[WindowsPath('foo'), WindowsPath('foo/bar'), WindowsPath('foo/bar')]\r\n```\r\nthen using a normal list it is necessary to use a loop:\r\n\r\n```python\r\n[p.parent for p in path_list]\r\n```\r\n\r\nbut using an ObjectList this can be done by\r\n```python\r\npath_objectlist.parent\r\n```\r\n\r\nObjectLists can be easily converted to strings:\r\n```python\r\npath_objectlist.parent.str\r\n```\r\n\r\n```plaintext\r\n['foo', 'foo\\\\bar', 'foo\\\\bar']\r\n```\r\n\r\n### Using object methods and passing arguments\r\nObject methods can also be used\r\n\r\n```python\r\npath_objectlist.with_suffix('.txt')\r\n```\r\n```plaintext\r\n[WindowsPath('foo/a.txt'), WindowsPath('foo/bar/b.txt'), WindowsPath('foo/bar/c.txt')]\r\n```\r\n\r\n### Using parallel processing\r\n\r\nParallel processing can be activated on existing ObjectLists by using .parallel \r\n\r\n```python\r\npath_objectlist.parallel.with_suffix('.txt')\r\n```\r\n\r\nAlternatively parallel processing can be activated when the ObjectList is defined: \r\n\r\n```python\r\npath_objectlist = ObjectList(path_list, \r\n                             use_parallel_processing=True, \r\n                             number_of_cores=None,\r\n                             parallel_processing_kwargs=dict(verbose=0), \r\n                             return_none_if_all_none=True)\r\n```\r\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Use methods and method chaining on lists of objects.",
    "version": "1.0.2",
    "project_urls": {
        "Homepage": "https://github.com/ivoseverins/objectlist"
    },
    "split_keywords": [
        "object",
        "list",
        "method",
        "chaining"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "add767a38f79e8912703ca78e0669c6b93893b742843a30fa6bc61c7e1b039ab",
                "md5": "548ab93bf90aa7f739aceb4f2387e657",
                "sha256": "f6e4cd31810785b233fe13372a14293b379dcaa05e7851196050d6d52f786f05"
            },
            "downloads": -1,
            "filename": "objectlist-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "548ab93bf90aa7f739aceb4f2387e657",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 17208,
            "upload_time": "2024-02-13T15:46:46",
            "upload_time_iso_8601": "2024-02-13T15:46:46.328006Z",
            "url": "https://files.pythonhosted.org/packages/ad/d7/67a38f79e8912703ca78e0669c6b93893b742843a30fa6bc61c7e1b039ab/objectlist-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "eca092b191513ff703b0ce661d0776dc97324dfafeac2d3de2943252126f6330",
                "md5": "b797c37ec039499dd0168f093e1d6f18",
                "sha256": "8b3b54c28dc5deafec5e5cac4365aa0141adedd0d63b07ca6f69d5aab3547131"
            },
            "downloads": -1,
            "filename": "objectlist-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "b797c37ec039499dd0168f093e1d6f18",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 17269,
            "upload_time": "2024-02-13T15:46:49",
            "upload_time_iso_8601": "2024-02-13T15:46:49.400451Z",
            "url": "https://files.pythonhosted.org/packages/ec/a0/92b191513ff703b0ce661d0776dc97324dfafeac2d3de2943252126f6330/objectlist-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-13 15:46:49",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ivoseverins",
    "github_project": "objectlist",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "objectlist"
}
        
Elapsed time: 0.20609s