This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

Package (.m)

Registered MIME type:
Mathematica
package source format.
Used for storing and exchanging Mathematica programs, packages, and data.
Plain ASCII text format.
Stores Mathematica expressions in InputForm.
Can represent program code, numerical and textual data, 2D raster and vector images, 3D geometries, sound, and other kinds of data.
Developed since 1988 by Wolfram Research.
  • Import reads in a Mathematica package, evaluating each expression in it, and returning the last one.
  • Export exports a single expression to a package source file.
  • Import imports the specified element from a package source file.
  • Import imports multiple elements.
  • Export creates a Mathematica source file by treating expr as specifying element elem.
  • Export treats each as specifying the corresponding .
  • Export exports expr with the specified option elements taken to have the specified values.
  • Export uses rules to specify the elements to be exported.
  • Put can be used to export multiple expressions.
  • See the reference pages for full general information on Import and Export.
  • In the notebook front end, Save As can be used to export a notebook as a Mathematica package.
"Elements"list of elements and options available in this file
"Rules"full list of rules for each element and option
"Options"list of rules for options, properties, and settings
"ExpressionList"evaluates all expressions and returns the results as a list
"Get"reads and evaluates all expressions, returning the last one
"HeldExpressions"list of unevaluated expressions
"Comments"code comments
  • Import by default uses the element for Mathematica Package files.
Automaticuser comments
PageWidth78number of character widths per line
Show the Import elements available in a sample file:
Import unevaluated expressions from this file:
Export an arbitrary expression to the package format:
Import the previous output:
Show the Import elements available in a sample file:
In[1]:=
Click for copyable input
Out[1]=
Import unevaluated expressions from this file:
In[2]:=
Click for copyable input
Out[2]=
 
Export an arbitrary expression to the package format:
In[1]:=
Click for copyable input
Out[1]=
Import the previous output:
In[2]:=
Click for copyable input
Out[2]=