Python Forum
Review on (new) Python module: Function but Lazy Python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Review on (new) Python module: Function but Lazy Python
#1
Hello everyone, I have recently been working on a Python module and I wanted to have some feedback on it.

I really enjoy Python's syntax, except for iterators where I prefer a Rust-like syntax (functional programming) due to its readability. To this end, I began to work on a Python module that wraps any Python iterable into an object that allows for a Rust-like syntax.

I will write down below the basic example available on my PyPI project page.

Even though this project can be largely improved (see TODOs), I think it is yet usable and this is why I am looking for feedback from the community.
It can be about anything: bad or good project structure, lack of some features, whether you find interest or not in that, whether some Python module already does that (which I did not know), some tips, etc.

In advance, thanks!

Example

Given an input sequence x, print all, but the first, squared values that are divisible by 3 and collect the result into a list.

>>> x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]  # Input sequence

# Usual way

>>> squares = map(lambda v: v * v, x)
>>> squares_div_by_3 = filter(lambda v: v % 3 == 0, squares)
>>> y = list(squares_div_by_3)[1:]  # We skip one value
>>> for v in y:
...     print(v)
36
81
>>> y
[36, 81]

# FLPy way

>>> from flpy import It

>>> y = (
...     It(x)
...     .map('|v| v * v')  # You can also use lambda or any other callable
...     .filter('|v| v % 3 == 0')
...     .skip(1)
...     .collect()  # Collects the iterator into a list
...     .for_each('|v| print(v)')  # Yet it still returns the list to `y`
... )
36
81
>>> y
ItA<[36, 81]>
Reply


Messages In This Thread
Review on (new) Python module: Function but Lazy Python - by jeertmans - Oct-26-2021, 10:18 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python code review | Tkinter gui application Sr999 19 8,630 Dec-03-2023, 10:24 PM
Last Post: menator01
  First time python user - Calculator code review Steamy 1 3,109 Jul-22-2020, 05:59 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020