spy16 / pyschemes Goto Github PK
View Code? Open in Web Editor NEWPySchemes is a library for validating data structures in python
License: Do What The F*ck You Want To Public License
PySchemes is a library for validating data structures in python
License: Do What The F*ck You Want To Public License
Hi,
I came across pyschemes recently on HN. My question is where would someone use pyschemes? If it is supposed to be used in testing, how is it better than using asserts. Also is there a possibility of using this for type-checking function arguments?
What if we want to validate the value False (and other values which evaluate to False, like "" [] and 0)?
As in your example :
>>> def CustomValidator(value):
... if value == False or value in range(100):
... return value
... else:
... return False
...
>>> choices = validators.Any(["choiceA", "choiceB", "choiceC"])
>>> Scheme(choices).validate("choiceA")
'choiceA'
Instead of:
>>> Scheme(choices).validate("hello")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: value did not pass any validation
This would be clearer
>>> Scheme(choices).validate("hello")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: value was not one of "choiceA", "choiceB", "choiceC".
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.