Re: SetAttributes for entire package
- To: mathgroup at smc.vnet.net
- Subject: [mg111371] Re: SetAttributes for entire package
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Thu, 29 Jul 2010 06:43:41 -0400 (EDT)
On 7/28/10 at 2:54 AM, dbreiss at gmail.com (David Reiss) wrote:
>This would be quite simple if SetAttrubutes accepted string
>arguments. If it did then you could simply execute
>SetAttributes[#,{Locked, ReadProtected}]&[Names["mycontext`*]]
>where mycontext is your package context. Howe er SetAttributes does
>not work this way (but it should...).
>So one has to work around this. I had to do this years ago when
>creating a password protection scheme for
>http://scientificarts.com/worklife
You didn't say what your work around was. I note the following
In[1]:= BeginPackage["test`"];
f[x_] := 2 x
g[x_] := 1/x
EndPackage[];
In[5]:= SetAttributes[#, {Locked, ReadProtected}] & /@ Names["test`*"];
In[6]:= Attributes[g]
Out[6]= {Locked,ReadProtected}
In[7]:= Attributes[f]
Out[7]= {Locked,ReadProtected}
Given this does what you seem to want and requires about the
same number of keystrokes to enter, if you consider this a "work
around" I contend it doesn't involve any significant effort. And
given this does the job, it isn't clear to me any thing needs to
be changed.