Classes

Making a class with Elk is simple:

import elk

class Person(elk.Elk):
    ...

The elk.Elk base class simply ensures that your class uses the Elk metaclass and—on its own—has no other functionality.

The Elk metaclass will notice when you are using Elk attributes, roles or method modifiers and do some work to initialise your class properly. For example, you might define an attribute:

class Person(elk.Elk):
    tfn = elk.ElkAttribute(mode='ro', type=str)

Subclassing

Subclassing an Elk class is done in the usual way. The metaclass will be inherited from the base class:

class User(Person):
    username = elk.ElkAttribute(mode='rw')

Table Of Contents

Previous topic

Elk

Next topic

Attributes

This Page