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


Groups > comp.lang.python > #18550 > unrolled thread

Re: a little help

Started byDennis Lee Bieber <wlfraed@ix.netcom.com>
First post2012-01-05 10:35 -0500
Last post2012-01-05 10:35 -0500
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#18550 — Re: a little help

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2012-01-05 10:35 -0500
SubjectRe: a little help
Message-ID<mailman.4452.1325778317.27778.python-list@python.org>
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/

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web