Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Based on the pipe library, adding more utilities and pipes to it
Some pipes are inspired by other programming languages (eg Rust)
pip install morepipes
Consume iterable
range(9) | where(lambda x: x % 2) | collect
# List of odd numbers
Cut iterables
range(9) | take(5) | drop(2) | collect
# [2, 3, 4]
Remove duplicates
a = [1, 3, 3, 1, 2, 4, 4, 2, 2, 2, 1, 4, 4, 3, 3, 1]
b = a | squeeze | collect
# [1, 3, 1, 2, 4, 2, 1, 4, 3, 1], remove consecutive duplicates
c = b | unique | collect
# [1, 3, 2, 4]
Manipulate iterations
range(9) | chunks(4)
# [[0, 1, 2, 3], [4, 5, 6, 7]]
range(9) | alternate
# [0, 2, 4, 6, 8]
Side effects
range(9) | ... | inspect | ...
# Prints out each object received on evaluation
Or, more generally
range(9) | ... | foreach(print) | ...
There's also bindings for builtins and itertools
[1, 2, 3] | combinations(2)
[1, 2, 3] | permutations
[1, 2, 3] | cycle
[1, 2, 3] | imap(iseven)
[1, 2, 3] | isum # 6, equivalent to sum([1, 2, 3])
[1, 2, 3] | iall(iseven) # equivalent to all(iseven(x) for x in [1, 2, 3])
[1, 2, 3] | iany(iseven) # equivalent to any(iseven(x) for x in [1, 2, 3])
[1, 2, 3] | ilen # 3, equivalent to len([1, 2, 3])
isum
, iall
, iany
, ilen
is useful when working with long pipe chains (no messy parentheses)
Creating a partial pipe
reverse_sort = P | reverse | sort
# P is a special object placeholder
Using a partial pipe
[1, 3, 4, 2] | reverse_sort
# Just like any other pipe
# Strictly equivalent to:
[1, 3, 4, 2] | reverse | sort
# as if P is replaced by [1, 3, 4, 2]
Have fun!
pipe
library)chunk
for sequences (supports slicing)FAQs
Extended pipes for functional programming
We found that morepipes demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.