WOLFRAM

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

Examples

open allclose all

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

Out[2]=2
Out[2]=2

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

Add an attribute to the list of attributes of a symbol:

Add more attributes; the previous ones are retained:

Out[3]=3

Add several attributes:

Add the same attributes to several symbols:

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

Set a single attribute for the symbols f and g:

SetAttributes adds to the already existing attributes; Attributes[g]={..} resets the list:

Out[3]=3

SetAttributes is equivalent to this assignment to the attributes:

Out[1]=1

Use ClearAttributes to clear a particular attribute:

Out[3]=3

Protecting a symbol is equivalent to setting the Protected attribute:

Out[2]=2

You can still change the attributes of a protected symbol:

After setting the attribute Locked, no more changes to the attributes can be made:

A locked symbol can no longer be unprotected, as the Protected attribute cannot be cleared:

Out[2]=2

SetAttributes has the attribute HoldFirst:

Out[1]=1

This sets attributes of the symbol syms itself:

Out[4]=4

This sets the attributes of all symbols in the list syms:

Out[6]=6

Neat Examples  (1)Surprising or curious use cases

The 10 system symbols with the most attributes:

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

Text

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

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.

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

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

BibTeX

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

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

BibLaTeX

@online{reference.wolfram_2025_setattributes, organization={Wolfram Research}, title={SetAttributes}, year={1988}, url={https://reference.wolfram.com/language/ref/SetAttributes.html}, note=[Accessed: 29-March-2025 ]}

@online{reference.wolfram_2025_setattributes, organization={Wolfram Research}, title={SetAttributes}, year={1988}, url={https://reference.wolfram.com/language/ref/SetAttributes.html}, note=[Accessed: 29-March-2025 ]}