Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.04; 'interpreter': 0.05; 'lines.': 0.05; 'passes': 0.05; 'behave': 0.07; 'python': 0.08; 'andres': 0.09; 'namespace': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'am,': 0.12; 'callback': 0.16; 'definition.': 0.16; 'namespace,': 0.16; 'namespace.': 0.16; 'prolog,': 0.16; 're-run': 0.16; 'reimport': 0.16; 'reload': 0.16; 'wrote:': 0.18; 'functions,': 0.18; 'ryan': 0.18; 'memory': 0.21; 'subject:help': 0.21; 'maybe': 0.21; 'header :In-Reply-To:1': 0.22; 'command': 0.24; 'compiled': 0.25; 'code': 0.25; 'module': 0.26; 'function': 0.27; 'code,': 0.27; 'do.': 0.28; '(and': 0.28; 'replaced': 0.29; 'problem': 0.29; 'definition': 0.30; 'imported': 0.30; 'usually': 0.31; 'change.': 0.32; 'header:User-Agent:1': 0.33; 'header:X-Complaints-To:1': 0.33; 'that,': 0.33; 'there': 0.33; 'to:addr:python-list': 0.34; 'elegant': 0.34; 'lie': 0.34; 'restrict': 0.34; 'thank': 0.35; 'explain': 0.36; 'received:au': 0.36; 'thursday,': 0.37; 'variables': 0.37; 'but': 0.37; 'could': 0.37; 'using': 0.38; 'received:org': 0.38; 'comments': 0.38; 'either': 0.39; 'help': 0.39; 'to:addr:python.org': 0.40; 'happens': 0.40; 'more': 0.61; 'your': 0.61; 'alternative': 0.65; '2012': 0.67; 'yourself': 0.69; '11:29': 0.84; 'pasting': 0.84; 'prolog': 0.84; 'subject:little': 0.91; 'received:110': 0.95 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Lie Ryan Subject: Re: a little help Date: Fri, 06 Jan 2012 06:53:34 +1100 References: <1325719533.2934.YahooMailNeo@web30605.mail.mud.yahoo.com> <1325721417.64653.YahooMailNeo@web30608.mail.mud.yahoo.com> <1325723382.2402.YahooMailNeo@web30608.mail.mud.yahoo.com> <1325779451.13916.YahooMailNeo@web30606.mail.mud.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 110-175-240-90.static.tpgi.com.au User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111124 Thunderbird/8.0 In-Reply-To: <1325779451.13916.YahooMailNeo@web30606.mail.mud.yahoo.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1325793228 news.xs4all.nl 6919 [2001:888:2000:d::a6]:59576 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:18560 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 > *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.