[Python-ideas] "Read Only" namespaces

Steven D'Aprano steve at pearwood.info
Sat Mar 29 18:46:44 CET 2014


On Sat, Mar 29, 2014 at 03:51:20PM +0000, Richard Prosser wrote:
> This is probably far-fetched where Python is concerned but I still think
> that it could be useful. It is based on an idea that I had 36 years ago!
> 
> Quite simply, the principle is to allow changes to variables within a
> function body (for example) but not outside of it, rather like the
> Functional Programming paradigm.

I'm afraid your description leaves me completely in the dark.

(1) What do you mean, "changes to variables? Do you mean rebinding, or 
mutation, or both?

e.g. "x = 1" is a binding; "x.append(1)" is a mutation.

(2) What is the scope of these variables? If they are local 
variables, by definition they aren't visible outside of the function 
body, so they cannot be rebound or mutated by anything outside. If 
they're global variables, then by definition they're supposed to be 
available outside of any function for rebinding and/or mutation.

If they're meant to be *constants*, not variables, then you should call 
them constants.

(3) Under what circumstances would you use this feature?

(4) What you describe doesn't sound like anything from Functional 
Programming that I know of. What is the connection that I am missing?

(5) I'm not seeing the connection between your description and "read 
only namespaces", the subject of your post. Can you explain?

(6) Later you describe this as "Persistent Variables". Persistent across 
what?

[...] 
> Any comments? Would a "Persistent Variables" PEP be interesting in its own
> right?

PEP stands for Python Enhancement Proposal. From your own description, 
you don't seem to be proposing this as an enhancement to the language, 
more like just an interesting idea for discussion, so a PEP would be 
completely inappropriate.

Do you have a blog? Perhaps this might be better started as a blog post 
or three. You can iron out any kinks in the idea and then reconsider 
whether or not it makes a serious proposal.


-- 
Steven


More information about the Python-ideas mailing list