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 file
  • parameters & arguments
  1. DOCS
  2. toml
  3. functions

maci.tomldump

dumps data to a file as toml

Last updated 1 year ago

dumping a file

Dumps a dictionary to a file formatted as TOML. Nothing is returned. Creates a new or overwrites an existing file by default (See to change mode).

Basic Example of dumping data to a file using default positional parameters

maci.tomldump('mydata.toml', data)

In this example, we simply dump data to a file using the tomldump function and pass a string of the filepath to the file as the first argument to the function, then pass the dictionary data as the second argument to the function.

parameters & arguments

Describes all parameter functionality and accepted data types

filename: str | Path

First required positional argument. Accepts strings and

Use this parameter to point to your filepath

data: dict[str, Any]

Second required positional argument. Accepts dictionaries

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

append: bool

Optional parameter. Accepts booleans. Default = False

Use this parameter to enable appending mode to write by appending data to the file. A new file will be created if the filename does not exist. Default is disabled which writes new or overwrites a file.

multi_line_str: bool

Optional parameter. Accepts booleans. Default = False

Use this parameter to enable writing string values as a multiline string. Default behavior is disabled matching the default for the tomli-w library.

This function uses the tomli-w library installed as a dependency from pypi as its underlying functionality. For more information on tomli-w, visit:

append parameter
Path objects
https://pypi.org/project/tomli-w/