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


Groups > comp.lang.python > #18560

Re: a little help

From Lie Ryan <lie.1296@gmail.com>
Subject Re: a little help
Date 2012-01-06 06:53 +1100
References (2 earlier) <1325721417.64653.YahooMailNeo@web30608.mail.mud.yahoo.com> <CAPTjJmqoJR=nPZwjRpAxfjfG2+Cd83AFdt4faxgA8WK3B014eg@mail.gmail.com> <1325723382.2402.YahooMailNeo@web30608.mail.mud.yahoo.com> <je3n3f$rfv$1@dough.gmane.org> <1325779451.13916.YahooMailNeo@web30606.mail.mud.yahoo.com>
Newsgroups comp.lang.python
Message-ID <mailman.4459.1325793228.27778.python-list@python.org> (permalink)

Show all headers | View raw


On 01/06/2012 03:04 AM, Andres Soto wrote:
>     Please, see my comments between your lines. Thank you very much for
>     your explanation!
>     *
>     *
>     *From:* Lie Ryan <lie.1296@gmail.com>
>     *To:* python-list@python.org
>     *Sent:* Thursday, January 5, 2012 2:30 AM
>     *Subject:* Re: a little help
>
>     On 01/05/2012 11:29 AM, Andres Soto 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.
>      > 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.
>
>     it is usually trivial to redefine state-free functions, you just
>     need to copy and paste the new code into the shell.
>
>     &&&yes, I am already using that, but I thought that maybe there were
>     a more elegant way. In Prolog, you just have to reload the code and
>     nothing happens with the global variables

Alternative to copy pasting is to reload the module; but that comes with 
the caution that the old function/class definition may still be lying 
around in the global namespace if you imported them into your global 
namespace, so you had to either restrict yourself to using 
class/function using the module namespace or you had to remember to 
reimport them into your global namespace. You also need to be careful if 
you passes a module function as callbacks, as the callback will not be 
automatically replaced with the new definition.

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


Thread

Re: a little help Lie Ryan <lie.1296@gmail.com> - 2012-01-06 06:53 +1100

csiph-web