Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

Simple Models for Python

Project description

SimpleModel offers a simple way to handle data using classes instead of a plenty of lists and dicts.

It has simple objectives:

  • Define your fields easily (just a tuple, not dicts or instances from type classes whatever)
  • Support for field validation
  • Serialize to dict

That’s it. If you want something more complex there are plenty of libraries and frameworks that does a lot of cool stuff.

How to use

::
class Person:

fields = (‘name’, ‘age’, ‘gender’, ‘height’, ‘weight’) allow_empty = (‘height’, ‘weight’)

def validate_age(self, value):
if 0 > value > 150:
raise ValidationError
def validate_gender(self, value):
if value not in (‘M’, ‘F’):
raise ValidationError
::
>> person = Person(name=’John Doe’, age=18, gender=’M’) >> person.name ‘John Doe’ >> person.validate() >> person.serialize() {‘name’: ‘John Doe’, ‘age’: 18, ‘gender’: ‘M’, ‘height’: ‘’, ‘weight’: ‘’}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pysimplemodel, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size pysimplemodel-0.0.1.tar.gz (2.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page