========
Functional style 'list' and 'dict' classes & decorators for pattern matching function dispatch.
For more information, visit http://www.systemical.com/doc/opensource/pyfnc
Examples
========
Dictionary class 'dic' with 'return self' functionality:
>>> d=dic({"k2":"v2"})
>>> dr=d.update({"k1":"v1"})
>>> self.assertEqual(d, dr)
List class 'liste' with 'return self' functionality and integrated 'map', 'reduce' and 'filter' functions:
>>> l=liste()
>>> lr=l.extend([1,2,3])
>>> self.assertEqual(len(l), 3)
>>> self.assertEqual(l, lr)
>>> f=lambda x:x+10
>>> lm=l.map(f)
>>> self.assertEqual(lm, [11, 12, 13])
>>> self.assertEqual(l, [11, 12, 13])
Erlang style function dispatch:
>>> @pattern('male', str)
... def greet_male(p1, p2):
... return "Hello M. %s!" % p2
>>> @pattern('female', str)
... def greet_female(p1, p2):
... return "Hello Mrs. %s!" % p2
>>> @patterned
... def greet(p1, p2):
... pass
>>> print greet("male", "Dupont")
"Hello M. Dupont!"
>>> print greet("female", "Corriveau")
"Hello Mrs. Corriveau!"
Clean looking reducers:
@pattern(False, any)
def comp_reducer_FA(p1, p2):
return False
@pattern(str, str)
def comp_reducer_SS(p1, p2):
if p1==p2:
return p1
return False
@patterned
def comp_reducer(p1, p2):
'''
Reducer
Check if all strings are equal
'''
def strings_comparator(l):
'''
Returns the common string if all elements of 'l' are equal
else returns False
'''
if len(l)<2:
return False
return reduce(comp_reducer, l)
Tests
=====
Tests can be performed using `nosetests` in the root directory.
Metadata
Release files for pyfnc 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distributions (sdists)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyfnc-0.1.2.zip | 13.6 kB | Without provenance | Details for pyfnc-0.1.2.zip | |
| pyfnc-0.1.2.tar.gz | 7.1 kB | Without provenance | Details for pyfnc-0.1.2.tar.gz |
Release files / pyfnc-0.1.2.zip
| Download URL | pyfnc-0.1.2.zip |
|---|---|
| Size | 13.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f1164c42a9c6d06c122c98b389e7b5d1c8f41ddc72cf9762c092fbaa4a851c47
|
|
BLAKE2b-256 checksum How to use checksums |
9219f7e93328e03153ca3b99a01c1d30ea69f274fc7880ffd29c3ad228d2f69c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pyfnc-0.1.2.tar.gz
| Download URL | pyfnc-0.1.2.tar.gz |
|---|---|
| Size | 7.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bcf621d2273449dd485b4208b16cbb4be357f8c8cd640a80af5652e7ab250d3e
|
|
BLAKE2b-256 checksum How to use checksums |
595661714cede2b627d71b83b3bd13750a79317f377558f82fcfc6aa0d8dc584
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for pyfnc 0.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.