Skip to main content
Fix typo
Source Link
Carl Woll
  • 132.7k
  • 6
  • 253
  • 366

This is a variation of Leonid's answer that avoids the dependence on a context like "Test`" that must be empty:

SetAttributes[fq, {Listable, HoldAll}]; fq[sym_] := Block[{Internal`$ContextMarks = True},[ToString[Unevaluated[sym]]]ToString[Unevaluated[sym]]] fq[{fq, Print, Developer`$MaxMachineInteger}] (* {"Global`fq", "System`Print", "Developer`$MaxMachineInteger"} *) 

This is a variation of Leonid's answer that avoids the dependence on a context like "Test`" that must be empty:

SetAttributes[fq, {Listable, HoldAll}]; fq[sym_] := Block[{Internal`$ContextMarks = True},[ToString[Unevaluated[sym]]] fq[{fq, Print, Developer`$MaxMachineInteger}] (* {"Global`fq", "System`Print", "Developer`$MaxMachineInteger"} *) 

This is a variation of Leonid's answer that avoids the dependence on a context like "Test`" that must be empty:

SetAttributes[fq, {Listable, HoldAll}]; fq[sym_] := Block[{Internal`$ContextMarks = True},ToString[Unevaluated[sym]]] fq[{fq, Print, Developer`$MaxMachineInteger}] (* {"Global`fq", "System`Print", "Developer`$MaxMachineInteger"} *) 
Source Link
ilian
  • 25.6k
  • 4
  • 118
  • 187

This is a variation of Leonid's answer that avoids the dependence on a context like "Test`" that must be empty:

SetAttributes[fq, {Listable, HoldAll}]; fq[sym_] := Block[{Internal`$ContextMarks = True},[ToString[Unevaluated[sym]]] fq[{fq, Print, Developer`$MaxMachineInteger}] (* {"Global`fq", "System`Print", "Developer`$MaxMachineInteger"} *)