Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #18550

Re: a little help

From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: a little help
Date 2012-01-05 10:35 -0500
References <1325719533.2934.YahooMailNeo@web30605.mail.mud.yahoo.com> <CAPTjJmqLPhuOuqzirjMxFk9GeqDhTYFhaoCZitKr+4XtpGVWfg@mail.gmail.com> <1325721417.64653.YahooMailNeo@web30608.mail.mud.yahoo.com> <CAPTjJmqoJR=nPZwjRpAxfjfG2+Cd83AFdt4faxgA8WK3B014eg@mail.gmail.com> <1325723382.2402.YahooMailNeo@web30608.mail.mud.yahoo.com>
Newsgroups comp.lang.python
Message-ID <mailman.4452.1325778317.27778.python-list@python.org> (permalink)

Show all headers | View raw


On Wed, 4 Jan 2012 16:29:42 -0800 (PST), Andres Soto
<soto_andres@yahoo.com> wrote:

>my mistake is because I have no problem to do that using Prolog which use an interpreter as Python. I thought that the variables in the main global memory space (associated with the command line environment) were kept, although the code that use it could change.

	The key, as with all of Python, is that "variable" NAMES are
references bound to objects. Re-importing a module will bind its name(s)
to new versions of the objects -- but anything created using the former
version are still bound to the older versions of the objects.

>As you explain me, Python behave like a compiled language: any time I make a change in the code, I have to "compile" it again, and re-run (and re-load the data). There is nothing to do.

	import mdl
	b = mdl.aName	#"b" is now bound to the same object as mdl.aName
	#edit the source of mdl
	reload(mdl)		#Python 2.x
	c = mdl.aName		#"c" is now bound to the new object of mdl.aName
	# but "b" is still bound to the old object version even though the 
	# old "mdl.aName" no longer exists, the object stays until ALL names
	# bound to it are deleted or rebound
	b = c		#rebind "b" to the new object version
				#the old object version is now free to be garbage
				#collected (if nothing else was bound to it)
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: a little help Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-01-05 10:35 -0500

csiph-web