This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

mutablerecords.Record

This is similar to collections.namedtuple, except it supports optional attributes and mutability. A class definition is generated (with __slots__, __str__ and other niceties), and can be used to instantiate new records of that type. The record can also be subclassed to add new attributes or to add methods to that data.

Sometimes, a Record definition is used to replace a simple __init__ method that only takes N arguments and sets them as instance variables. These __init__ methods are tedious to write and, even if you do, you still have to write str, hash, eq functions, and set __slots__ to be fully correct, but who has the time for that? With records, you get all of that in a single declaration, which you can even inline as your base class.

# This acts like a mutable namedtuple, taking the same arguments.
Simple = mutablerecords.Record('Simple', ['foo'])

# Now let's use a default argument.
SecondRecord = mutablerecords.Record('SecondRecord', ['attr1', 'attr2'], {'attr3': 0})
foo = SecondRecord(1, 2, attr3=3)
# str(foo) --> 'SecondRecord(attr1=1, attr2=2, attr3=3)'
bar = SecondRecord(attr1=1, attr2=2, attr3=5)
# str(bar) --> 'SecondRecord(attr1=1, attr2=2, attr3=5)'

class Third(SecondRecord):
    required_attributes = ['third1']
    optional_attributes = {'third2': 5}

# Third requires attr1, attr2, and third1.
baz = Third(1, 2, 3, third2=4)
# Here, second1 is required, so it goes before attr3:
# str(baz) --> 'Third(attr1=1, attr2=2, third1=3, attr3=0, third2=5)'

class OptionalMaker(mutablerecords.Record('Required', ['required'])):
    required = None
    required_attributes = ['other']

opt = OptionalMaker(1)
# OptionalMaker has a class attribute that matches the name of a
#   required_attribute (required), so it becomes an optional_attribute with a
#   default equal to the attribute value (None). It also defines a new
#   required attribute 'other', which is set in opt as 1:
# str(opt) --> 'OptionalMaker(other=1, required=None)'
opt2 = OptionalMaker(2, required=3)
# This time, opt2 has required set, too, which is still an attribute.
# str(opt2) --> 'OptionalMaker(other=2, required=3)'

mutablerecords.HashableRecord

All this does is add a __hash__ implementation for when the record will be hashed, such as when a key in a dict or in a set.

mutablerecords.CopyRecord

This will copy a record and all of its fields. If a field is set to a Record instance, then it is also copied using CopyRecord. A future feature may also check for collections of Records, such as tuples or lists of instances, and recurse into those as well.

Release History

Release History

0.4.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.4.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.9

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.8

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.7

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.6

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.5

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
mutablerecords-0.4.1-py2-none-any.whl (7.2 kB) Copy SHA256 Checksum SHA256 py2 Wheel Aug 12, 2016
mutablerecords-0.4.1.tar.gz (5.1 kB) Copy SHA256 Checksum SHA256 Source Aug 12, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting