<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content=text/html;charset=ISO-8859-1>
<META content="MSHTML 6.00.2900.2668" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=#000000 bgColor=#ffffff>
<DIV><FONT face=Arial size=2>While we're on the subject of python, ive taken a 
look at most of the python scripts, and come across some things that were a 
little odd.. for instance, the scoring system, how many point you get per kill, 
death, team kill etc, is all editable in the python files, no wonder EA 
restricted the ranked servers, anyone can edit these files to give more points 
per kill etc etc .. just slightly odd that DICE have made these files so easily 
"moddable"? if thats the right word to use.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Nigel</FONT></DIV>
<BLOCKQUOTE dir=ltr 
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV 
  style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B> 
  <A title=thiessen@alum.mit.edu href="mailto:thiessen@alum.mit.edu">Forrest 
  Thiessen</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>To:</B> <A title=bf1942@icculus.org 
  href="mailto:bf1942@icculus.org">bf1942@icculus.org</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>Sent:</B> Saturday, June 25, 2005 10:34 
  PM</DIV>
  <DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [bf1942] Disconnecting after 
  every round</DIV>
  <DIV><BR></DIV>ScratchMonkey wrote: 
  <BLOCKQUOTE cite=mid225B12DDF7B224BBD4366E43@%5B10.0.0.14%5D 
    type="cite">--On Saturday, June 25, 2005 9:50 PM +0100 Paul Bowsher <A 
    class=moz-txt-link-rfc2396E 
    href="mailto:paul.bowsher@gmail.com>">&lt;paul.bowsher@gmail.com&gt;</A> 
    wrote: <BR>
    <BLOCKQUOTE type="cite">Yeah, it's VERY annoying that you have to restart 
      the server for the <BR>new python to take effect. Anyone know if there's 
      an ACTUAL reason for <BR>this? <BR></BLOCKQUOTE>It's probably like Perl: The 
    code is tokenized and "compiled" to p-code when&nbsp; initially loaded, and 
    it's the p-code that's "executed". The file on disk is never looked at again 
    until the interpreter is reloaded. <BR></BLOCKQUOTE>
  <DIV class=moz-text-plain lang=x-western 
  style="FONT-SIZE: 13px; FONT-FAMILY: -moz-fixed" graphical-quote="true" 
  wrap="true"><PRE wrap="">That's all correct, but not why the server has to be restarted. . .

Python does indeed "compile" programs when they are first loaded
(sometimes you'll see ".pyc" files instead of the regular ".py"
files--those are programs that have been saved after having been
tokenized, etc.).

However, Python is a dynamic language, and one property of such
languages is that you can change their code during runtime, while they
are executing.  So, theoretically, there is no reason why you can't have
changes to Python code take effect immediately.

The trick is that you have to write your code with the intention of
allowing this, if it's what you want.  Because people don't normally
change running programs on the fly, Python gains some efficiencies by
assuming you're not going to do it.  For example, if you want to run
code in another module you first have to "import" it.  Python only
imports any given module once--on the assumption that it's not going to
change--so if you do change it and want the changes to take effect, you
can't just import it again; there's a separate "reload" statement that
you have to use if you want to tell Python that the module has changed
and it really should look at your module again.

Part of the problem, too, is that the architecture DICE used assumes
static code; they only import and instantiate objects like
bf2.playerManager once, when the server first starts up, so even if you
change it, and change it's import statement to a "reload", the
bf2.playerManager object has already been created, so changing it's
class has no effect.

There are still ways through this maze--bf2.playerManager, for example,
is just a pointer to an object, so you can assign it to point to a
different object while the program is running, if you want, and then all
method calls against it will go to your new, revised object, like
magic.  This all starts to get pretty twisted, though. . .

So, rather than rewriting everything in tricky ways so that you can
dynamically change the code, given the overall architecture DICE set up,
it's a lot easier (if annoying) to just restart the server.

--Forrest


</PRE>
  <BLOCKQUOTE type="cite"><PRE wrap=""><SPAN class=moz-txt-citetags>&gt; </SPAN>--On Saturday, June 25, 2005 9:50 PM +0100 Paul Bowsher
<SPAN class=moz-txt-citetags>&gt; </SPAN><A class=moz-txt-link-rfc2396E href="mailto:paul.bowsher@gmail.com">&lt;paul.bowsher@gmail.com&gt;</A> wrote:
<SPAN class=moz-txt-citetags>&gt;</SPAN>
  </PRE>
    <BLOCKQUOTE type="cite"><PRE wrap=""><SPAN class=moz-txt-citetags>&gt;&gt; </SPAN>Yeah, it's VERY annoying that you have to restart the server for the
<SPAN class=moz-txt-citetags>&gt;&gt; </SPAN>new python to take effect. Anyone know if there's an ACTUAL reason for
<SPAN class=moz-txt-citetags>&gt;&gt; </SPAN>this?
    </PRE></BLOCKQUOTE><PRE wrap=""><SPAN class=moz-txt-citetags>&gt;</SPAN>
<SPAN class=moz-txt-citetags>&gt;</SPAN>
<SPAN class=moz-txt-citetags>&gt; </SPAN>It's probably like Perl: The code is tokenized and "compiled" to
<SPAN class=moz-txt-citetags>&gt; </SPAN>p-code when  initially loaded, and it's the p-code that's "executed".
<SPAN class=moz-txt-citetags>&gt; </SPAN>The file on disk is never looked at again until the interpreter is
<SPAN class=moz-txt-citetags>&gt; </SPAN>reloaded.
<SPAN class=moz-txt-citetags>&gt;</SPAN>
<SPAN class=moz-txt-citetags>&gt;</SPAN>
  </PRE></BLOCKQUOTE><PRE wrap=""><!---->

</PRE></DIV></BLOCKQUOTE></BODY></HTML>