maci docs
  • maci
  • WATCH
    • Quick Start
    • Full Training Series
  • DOCS
    • maci
      • language
        • v1.0.0
      • functions
        • maci.build
        • maci.load
        • maci.loadstr
        • maci.loadattrs
        • maci.loadraw
        • maci.loaddict
        • maci.loadstrdict
        • maci.dump
        • maci.dumpstr
        • maci.dumpraw
      • object
        • methods
          • lock_attr
          • unlock_attr
          • hard_lock_attr
          • map_attr
          • unmap_attr
          • load_attrs
          • get_attrs
          • get_locked_list
          • get_hard_locked_list
          • get_all_maps
          • get_parent_maps
          • get_child_maps
          • get_parent_map_chains
          • is_parent_map
          • is_child_map
      • errors
      • hints
    • json
      • functions
        • maci.jsonload
        • maci.jsonloadstr
        • maci.jsondump
        • maci.jsondumpstr
    • yaml
      • functions
        • maci.yamlload
        • maci.yamlloadstr
        • maci.yamlloadall
        • maci.yamldump
        • maci.yamldumpstr
        • maci.yamldumpall
    • toml
      • functions
        • maci.tomlload
        • maci.tomlloadstr
        • maci.tomldump
        • maci.tomldumpstr
    • ini
      • functions
        • maci.iniload
        • maci.inidump
        • maci.inibuildauto
        • maci.inibuildmanual
    • xml
      • functions
        • maci.xmlload
        • maci.xmlloadstr
        • maci.xmlloaddict
        • maci.xmlloadstrdict
        • maci.xmldump
        • maci.xmldumpstr
        • maci.xmldumpdict
        • maci.xmldumpstrdict
        • maci.xmlbuildmanual
        • maci._defuse_xml_stdlib
    • pickle
      • functions
        • maci.pickleloadbytes
        • maci.pickledumpbytes
    • tools
      • hash functions
        • maci.createhash
        • maci.createfilehash
        • maci.comparefilehash
      • format functions
        • maci.cleanformat
  • Updates
    • Changelog
      • v1.1.0
      • v1.0.0
Powered by GitBook
On this page
  • dumping a string
  • parameters & arguments
  1. DOCS
  2. maci
  3. functions

maci.dumpstr

dumps maci, dict, or object data to a string

Last updated 1 year ago

dumping a string

Dumps maci, dict, or custom object data to a string. The returned string is a structured format following the maci language syntax (See ).

maci.dumpstr -> str

Basic Example of dumping data to a string using default positional parameter

data = maci.dumpstr(mydata)

In this example, we simply dump data to a string using the dump function and pass the data as an argument to the function, and assign the returned data to a variable.

Example of dumping

maci_obj.mydata1 = 'data1'
maci_obj.mydata2 = 2

data = maci.dumpstr(maci_obj)

Example of dumping dict

dict_data = {'mydata1': 'data1', 'mydata2': 2}

data = maci.dumpstr(dict_data)

Example of dumping custom object

my_object.mydata1 = 'data1'
my_object.mydata2 = 2

data = maci.dumpstr(my_object)

Resulted output contents in example string from all object dumps

"mydata1 = 'data1'\nmydata2 = 2"

parameters & arguments

Describes all parameter functionality and accepted data types

data: MaciDataObj | dict | ClassObject

First and only required positional argument. Accepts maci data objects, dictionaries, or custom objects.

Use this parameter to pass in the data you want to dump to a string.

indent_level: int

Optional parameter. Accepts integers. Default = 1

Use this parameter to change the indentation level for structured data (lists, dicts, tuples, sets) written to the string. Indentation will be applied to nested data as well.

Default uses the standard 4x spaces indentation practice. A single integer represents adding 4x more spaces at each level. For example 1 = 4x spaces, 2 = 8x spaces, 3 = 12x spaces, etc.

Note: Setting it to 0 will slightly improve write performance by approx 5%.

indentation_on: bool

Optional parameter. Accepts booleans. Default = True

Use this parameter to enable/disable setting and indenting structured data (lists, dicts, tuples, sets) over multiple lines.

Note: Disabling indentation will slightly improve write performance by approx 5%, but output of structured data may be less human-readable.

multi_line_str: bool

Optional parameter. Accepts booleans. Default = False

private_attrs: bool

Optional parameter. Accepts booleans. Default = False

Use this parameter to also dump all private attribute names that begin with a single or double underscore. Default is disabled to protect private or name-mangled attributes.

private_under_attrs: bool

Optional parameter. Accepts booleans. Default = False

Use this parameter to also dump all private attribute names that begin with a single underscore. Default is disabled to protect private attributes.

private_dunder_attrs: bool

Optional parameter. Accepts booleans. Default = False

Use this parameter to also dump all private attribute names that begin with a double underscore. Default is disabled to protect private/name-mangled attributes.

class_attrs: bool

Optional parameter. Accepts booleans. Default = False

Use this parameter to dump all attributes of the class. This can be useful if you also need the attributes of a class or class of an object to be stored along with the initialized attributes. Pass the class only if just wanting class attributes dumped.

Default is disabled as this may be undesirable to also store class attributes.

private_init_attrs: bool

Optional parameter. Accepts booleans. Default = False

private_init_under_attrs: bool

Optional parameter. Accepts booleans. Default = False

private_init_dunder_attrs: bool

Optional parameter. Accepts booleans. Default = False

private_class_attrs: bool

Optional parameter. Accepts booleans. Default = False

private_class_under_attrs: bool

Optional parameter. Accepts booleans. Default = False

private_class_dunder_attrs: bool

Optional parameter. Accepts booleans. Default = False

use_symbol_glyphs: bool

Optional parameter. Accepts booleans. Default = False

Use this parameter to enable writing data that contain strings to be written as a representation. This will represent your string like a python triple-quoted string in the output over multiple lines. This mechanic works by delimiting each new line of the string data when it detects a newline character.

Default is disabled as it would be more desirable for a developer to have string data in its original representation as this feature does add 1 leading and 1 trailing newline character to the string (See ), but does not tamper with the data in-between. However, you can enable this feature if you desire a more human-readable multiline string for your string data in the output. Loading the string with the function for example will not strip the leading and trailing newline characters for the reason of preserving the original string data in case it was intentionally written that way.

This is a global switch that affects initialized and class (if ) attributes.

This is a global switch that affects initialized and class (if ) attributes.

This is a global switch that affects initialized and class (if ) attributes.

Use this parameter to also dump all private initialized attribute names that begin with a single or double underscore. Default is disabled to protect private or name-mangled attributes. Note: Using this is only necessary if you have parameter enabled and want to only dump private or name-mangled initialized attributes and not private class attributes.

Use this parameter to also dump all private initialized attribute names that begin with a single underscore. Default is disabled to protect private attributes. Note: Using this is only necessary if you have parameter enabled and want to only dump private initialized attributes and not private class attributes.

Use this parameter to also dump all private initialized attribute names that begin with a double underscore. Default is disabled to protect private/name-mangled attributes. Note: Using this is only necessary if you have parameter enabled and want to only dump private/name-mangled initialized attributes and not private class attributes.

Use this parameter to also dump all private class attribute names that begin with a single or double underscore. Default is disabled to protect private or name-mangled attributes. Note: Using this is only necessary if you have parameter enabled and want to only dump private or name-mangled class attributes and not private initialized attributes.

Use this parameter to also dump all private class attribute names that begin with a single underscore. Default is disabled to protect private attributes. Note: Using this is only necessary if you have parameter enabled and want to only dump private class attributes and not private initialized attributes.

Use this parameter to also dump all private class attribute names that begin with a double underscore. Default is disabled to protect private/name-mangled attributes. Note: Using this is only necessary if you have parameter enabled and want to only dump private/name-mangled class attributes and not private initialized attributes.

Use this parameter to enable writing the as symbols instead of their default syntax. Default is disabled as this feature may not be supported in the future and is discouraged from using in general. It was only implemented as a courtesy to provide ported support (See ), but it is instead encouraged to use the main maci supported glyphs from the glyph legend.

language
MaciDataObj
multiline string
multiline data
load
enabled
enabled
enabled
class_attrs
class_attrs
class_attrs
class_attrs
class_attrs
class_attrs
Assignment Glyphs
ported mention