python list with pointer
Project description
Listr is python module that can be used to:
- iterate list through pointer/cursor
current(),next(),prev(),start(),end(). - iterate list through
iter()(without looping/queue-like)
installation
pip install listr
Example
# -*- coding: utf-8 -*-
from listr import Listr
import unittest
class ListrTest(unittest.TestCase):
def test_pointer(self):
t = Listr()
t.import_list(["one","two","three"])
self.assertEqual(t.current(), "one")
self.assertEqual(t.next(), "two")
self.assertEqual(t.next(), "three")
self.assertEqual(t.next(), "one")
self.assertEqual(t.prev(), "three")
self.assertEqual(t.start(), "one")
self.assertEqual(t.end(), "three")
def test_iterator(self):
t = Listr()
t.import_list(range(1,10))
for i in t.list:
self.assertEqual(i,t.iter())
self.assertEqual(t.iter_check(), False)
t.iter_reset()
self.assertEqual(t.iter_num, 0)
if __name__=="__main__":
unittest.main()
Hint
- you can access list through
Listr.listproperty/attribute. iter()can be access with python native iterator (Listr object is iterable).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
listr-1.0.1.tar.gz
(14.4 kB
view details)
File details
Details for the file listr-1.0.1.tar.gz.
File metadata
- Download URL: listr-1.0.1.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6f0219f91b1f79d0b859ee0f2872b58befa66288eac5dc511eb788e6c430b76
|
|
| MD5 |
b874e491657d299ac0222d99d5f233ca
|
|
| BLAKE2b-256 |
ea2bbd5b0fcd78d0d7ebc24893fd8897b9e133f3ee02a45ff6d17b38ddc6d3bd
|