Top

grizzled.misc module

Overview

The grizzled.misc module contains miscellanous functions and classes that don't seem to fit well in other modules.

Classes

class ReadOnly

A ReadOnly object wraps another object and prevents all the contained object's fields from being written. Example use:

from grizzled.misc import ReadOnly
from configparser import ConfigParser

config = ConfigParser()
config.read('/path/to/some/file', encoding='UTF-8')
roConfig = ReadOnly(config)

Any attempt to set fields within roConfig will cause a ReadOnlyObjectError to be raised.

The __class__ member of the instantiate ReadOnly class will be the class of the contained object, rather than ReadOnly (ConfigParser in the example). Similarly, the isinstance() built-in function will compare against the contained object's class. However, the type() built-in will return the ReadOnly class object.

Ancestors (in MRO)

Static methods

def __init__(

self, wrapped)

Create a new ReadOnly object that wraps the wrapped object and enforces read-only access to it.

Instance variables

var wrapped

class ReadOnlyObjectError

Thrown by ReadOnly to indicate an attempt to set a field.

Ancestors (in MRO)

Class variables

var args

Static methods

def __init__(

self, field_name, message)

Parameters

  • field_name (str): Name of the field
  • message (str): Exception message

Instance variables

var field_name