PyTlin
Module implementing the Kotlin functions also, let, and run in Python. Additionally it includes sh-like (and Mathematica-like) piping syntax.
The Kotlin functions are documented in here.
Install
pip install PyTlin
Syntax
from PyTlin import k
k(obj).let(func).also(func)
k.run(func)
k(obj) | func1 | func2 | ...
k(obj) @ func1 @ func2 @ ...
Here all expressions (except k.run(func)) is wrapped in the class k. To recover obj one can apply either of these
k(obj).end
k(obj) | 'end'
k(obj) | 0
k(obj) @ 'end'
k(obj) @ 0
Example
from PyTlin import k
class Person:
def __init__(self,name,age):
self.name = name
self.age = age
def __repr__(self):
return '%s, %d' % (self.name, self.age)
def increaseAge(self):
self.age = self.age + 1
def nameToUpperCase(self):
self.name = self.name.upper()
student = Person('Pete', 18)
print(student) #Pete, 18
let
name = k(student).let(lambda x: (print(x),x.name)[1]) #Pete, 18
print(name) #Pete
also
newstudent = k(student).also(lambda x: (x.increaseAge(), x.nameToUpperCase()))
print(newstudent) #PETE, 19
run
mood = 'sad'
k.run(lambda mood = 'happy': print(mood)) #happy
print(mood) #sad
Piping
Piping can be done with either .let or with pipe operators @ (Mathematica-like in reverse order) or | (sh-like).
ops=k(4).let(lambda x: x*2).let(lambda x: x+3)
print(ops) #11
print(type(ops)) #<class 'PyTlin.k'>
print(ops.end) #11
print(type(ops.end)) #<class 'int'>
print(ops.end ==
k(4) @ (lambda x: x*2) @ (lambda x: x+3) @ 'end') #True
print(ops.end ==
k(4) | (lambda x: x*2) | (lambda x: x+3) | 0) #True
Metadata
Release files for PyTlin 1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| PyTlin-1.2.tar.gz | 2.0 kB | Without provenance | Details for PyTlin-1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| PyTlin-1.2-py3-none-any.whl | Python 3 | none | any | Details for PyTlin-1.2-py3-none-any.whl |
Total release size: 5.9 kB
Release files / PyTlin-1.2.tar.gz
| Download URL | PyTlin-1.2.tar.gz |
|---|---|
| Size | 2.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9cfd11488708c55db4d97ff2d7c802867e34f4e37a42faa2ba1a8b62355c6140
|
|
BLAKE2b-256 checksum How to use checksums |
fac20c6cfa86895c8cbf558b2942c8cd6e6f748eb6e0a0627e5c1fdbe17cae36
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / PyTlin-1.2-py3-none-any.whl
| Download URL | PyTlin-1.2-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a85502cb32f9f594d59376a4f7912a9e6a0576c4f7632ec55b38b46d4acb253b
|
|
BLAKE2b-256 checksum How to use checksums |
48167c7ce59bcc3b2d4689b96eed0ecad8a493c78c34aa2ff376d3b0a7b9d0c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for PyTlin 1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.