WOLFRAM

Save["filename",symbol]

appends definitions associated with the specified symbol to a file.

Save["filename","patt"]

appends definitions associated with all symbols whose names match the string pattern "patt".

Save["filename","context`"]

appends definitions associated with all symbols in the specified context.

Save["filename",{object1,object2,}]

appends definitions associated with several objects.

Details and Options

  • Save uses FullDefinition to include subsidiary definitions.
  • Save writes out definitions in InputForm.
  • Save uses Names to find symbols whose names match a given string pattern.
  • You can use Save["filename","s"] to write out the definition for the value of a symbol s itself.
  • Save works with local and cloud objects.
  • Save[File["filename"],] is also supported.
  • The following options can be given:
  • ExcludedContexts Automaticcontexts excluded from recursive inclusion
    IncludedContexts Allcontexts considered for recursive inclusion

Examples

open allclose all

Basic Examples  (2)Summary of the most common use cases

Create a temporary file:

Out[1]=1

Store a value in a variable:

Save the value of the variable in a file:

Loading the file restores the value of a:

Out[6]=6

Create multiple definitions to save:

Save the definitions to standard out to see how they would be written to a file:

Scope  (3)Survey of the scope of standard use cases

Save a definition into a file specified by the File object:

Out[1]=1
Out[5]=5

Local objects can be used with Save to save definitions persistently:

Out[2]=2

Cloud objects can be used with Save to save definitions in the cloud:

Out[2]=2

Options  (2)Common values & functionality for each option

ExcludedContexts  (1)

By default, certain system-internal contexts are excluded from recursive inclusions:

Use ExcludedContexts{} to save definitions of all non-protected symbols:

IncludedContexts  (1)

Limit recursive inclusion of symbols to the contexts "c1`" and "c2`" only:

Applications  (1)Sample problems that can be solved with this function

Save all definitions in the default context:

Properties & Relations  (3)Properties of the function, and connections to other functions

Save writes the output of FullDefinition to a file:

Saved definitions can be read into the Wolfram Language using Get:

Out[2]=2

Print the contents of the saved file:

Clear definitions in the current session:

Out[5]=5

Get the definitions into the current session:

Out[7]=7

By default, definitions attached to "System`" symbols are not pulled in:

Use ExcludedContexts{} to pull in definitions from all contexts:

Alternatively, attach definitions to your own symbols:

Out[3]=3
Wolfram Research (1988), Save, Wolfram Language function, https://reference.wolfram.com/language/ref/Save.html (updated 2021).
Wolfram Research (1988), Save, Wolfram Language function, https://reference.wolfram.com/language/ref/Save.html (updated 2021).

Text

Wolfram Research (1988), Save, Wolfram Language function, https://reference.wolfram.com/language/ref/Save.html (updated 2021).

Wolfram Research (1988), Save, Wolfram Language function, https://reference.wolfram.com/language/ref/Save.html (updated 2021).

CMS

Wolfram Language. 1988. "Save." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/Save.html.

Wolfram Language. 1988. "Save." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/Save.html.

APA

Wolfram Language. (1988). Save. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Save.html

Wolfram Language. (1988). Save. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Save.html

BibTeX

@misc{reference.wolfram_2025_save, author="Wolfram Research", title="{Save}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/Save.html}", note=[Accessed: 27-March-2025 ]}

@misc{reference.wolfram_2025_save, author="Wolfram Research", title="{Save}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/Save.html}", note=[Accessed: 27-March-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_save, organization={Wolfram Research}, title={Save}, year={2021}, url={https://reference.wolfram.com/language/ref/Save.html}, note=[Accessed: 27-March-2025 ]}

@online{reference.wolfram_2025_save, organization={Wolfram Research}, title={Save}, year={2021}, url={https://reference.wolfram.com/language/ref/Save.html}, note=[Accessed: 27-March-2025 ]}