SetAttributes[symbol,attr]
adds attr to the list of attributes of the symbol symbol.
SetAttributes["symbol",attr]
adds attr to the attributes of the symbol named "symbol" if it exists.
SetAttributes[s,{attr1,attr2,…}]
sets several attributes at a time.
SetAttributes[{s1,s2,…},attrs]
sets attributes of several symbols at a time.
SetAttributes
SetAttributes[symbol,attr]
adds attr to the list of attributes of the symbol symbol.
SetAttributes["symbol",attr]
adds attr to the attributes of the symbol named "symbol" if it exists.
SetAttributes[s,{attr1,attr2,…}]
sets several attributes at a time.
SetAttributes[{s1,s2,…},attrs]
sets attributes of several symbols at a time.
Details
- SetAttributes modifies Attributes[s].
- SetAttributes has attribute HoldFirst.
- SetAttributes does not affect symbols with the attribute Locked.
Examples
open all close allBasic Examples (2)
Scope (3)
Add an attribute to the list of attributes of a symbol:
SetAttributes[f, Flat]Add more attributes; the previous ones are retained:
SetAttributes[f, Orderless]Attributes[f]SetAttributes[f, {HoldAll, Protected}]Add the same attributes to several symbols:
SetAttributes[{f, g, h}, {HoldFirst, NHoldFirst}]Properties & Relations (6)
Set a single attribute for the symbols f and g:
Attributes[f] = Listable;
Attributes[g] = Listable;SetAttributes adds to the already existing attributes; Attributes[g]={..} resets the list:
SetAttributes[f, HoldAll];
Attributes[g] = HoldAll;Attributes[{f, g}]SetAttributes is equivalent to this assignment to the attributes:
Attributes[f] = Union[Attributes[f], {HoldFirst, NHoldFirst}]Use ClearAttributes to clear a particular attribute:
SetAttributes[f, {Flat, Orderless, OneIdentity}]ClearAttributes[f, OneIdentity]Attributes[f]Protecting a symbol is equivalent to setting the Protected attribute:
Protect[f];
SetAttributes[g, Protected];Attributes[{f, g}]You can still change the attributes of a protected symbol:
ClearAttributes[f, Protected];
Unprotect[g];After setting the attribute Locked, no more changes to the attributes can be made:
SetAttributes[f, {Locked, Protected}]A locked symbol can no longer be unprotected, as the Protected attribute cannot be cleared:
Unprotect[f]SetAttributes has the attribute HoldFirst:
Attributes[SetAttributes]syms = {f, g, h};This sets attributes of the symbol syms itself:
SetAttributes[syms, Protected]Attributes[syms]This sets the attributes of all symbols in the list syms:
SetAttributes[Evaluate[syms], Protected]Attributes[{f, g, h}]See Also
Tech Notes
Related Guides
History
Introduced in 1988 (1.0)
Text
Wolfram Research (1988), SetAttributes, Wolfram Language function, https://reference.wolfram.com/language/ref/SetAttributes.html.
CMS
Wolfram Language. 1988. "SetAttributes." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SetAttributes.html.
APA
Wolfram Language. (1988). SetAttributes. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SetAttributes.html
BibTeX
@misc{reference.wolfram_2026_setattributes, author="Wolfram Research", title="{SetAttributes}", year="1988", howpublished="\url{https://reference.wolfram.com/language/ref/SetAttributes.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_setattributes, organization={Wolfram Research}, title={SetAttributes}, year={1988}, url={https://reference.wolfram.com/language/ref/SetAttributes.html}, note=[Accessed: 13-June-2026]}