[Tutor] What exactly is "state"?
Dave Angel
davea at davea.name
Mon Mar 2 19:03:46 CET 2015
On 03/02/2015 11:25 AM, Sydney Shall wrote:
> I am a beginner and I am now at the strage of learning to write unittests.
> I have followed the current discussion entitled "How to test a class in
> pyhton", and I am not clear precisely what is meant by state. In its
> common meaning I can see some relevance. But is there a technical aspect
> to the notion. I see it mentioned often and feel rather uncomfortable
> that I know so little about it.
> I have deliberately started a new thread.
> Thanks.
When I started composing this, there were no other replies. Sorry for
any duplication caused by that.
Starting with a dictionary definition:
http://www.merriam-webster.com/dictionary/state
"the overall physical condition of something : the ability of something
to be used, enjoyed, etc."
Others:
"The particular condition that someone or something is in at a specific
time"
"In computer science and automata theory, the state of a digital logic
circuit or computer program is a technical term for all the stored
information, at a given instant in time, to which the circuit or program
has access."
That last comes the closest to what I'd like to explain.
For a given fragment of executing code, the state includes all local
variables, all parameters, all closures, all visible globals (ie the
ones that *could* be visible to the code. It also includes indirectly
the values of all environment variables, lots of system information like
the current directory, the time, the network IP address. It also
includes the current phase of the moon, the astrological sign of the
current president of France, and the number of specs of sand on the
eastern shore of a certain Martian lake.
--
DaveA
More information about the Tutor
mailing list