[python-win32] ASP Python

Marc Miller giant_lizard_of_death@hotmail.com
Tue, 10 Jul 2001 00:19:47 -0700


------=_NextPart_001_0000_01C108D6.06A69AD0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

Do people do serious ASP programming in Python?  I've recently been doing=
 somewhat-serious ASP programming in Perl and have started investigating =
Python as an alternative.  The lack of thorough documentation and reasona=
ble examples struck me, but that didn't stop me from entering the Perl AS=
P world :-).  Anyway, I've got two questions that maybe someone can help =
me with.

The first question deals with assigning to COM object properties which ta=
ke arguments.  A very similar question was asked in April by Gregory P. S=
mith ("assigning vb properties from python via COM").  Consider the follo=
wing piece of JScript code:

 // example JScript code
 Application('x') =3D 4;
 Response.Write(Application('x'));

The output is "4".  This example doesn't compile in python-land; you get =
an error because you're assigning to the result of a function call.  I th=
ink there was some confusion on the other thread, so let me just expand o=
n what's happening here: JScript is calling the default method on the app=
lication object, "Value", so this is equivalent to the following JScript =
code:


 // example JScript code
 Application.Value('x') =3D 4;
 Response.Write(Application('x'));

JScript actually turns the assignment into a single COM call which is equ=
ivalent to this pseudo-C++ code:

 // equivalent pseudo-C++ code
 VARIANT v =3D { 0 };   // put =E2=80=9C4=E2=80=9D inside a variant
 v.vt      =3D VT_I4;
 v.lval    =3D 4;

 BSTR  bstrPropName =3D SysAllocString(=E2=80=9Cx=E2=80=9D);

 // assume pApplication is of type IApplicationObject (see asp.dll)
 pApplication->put_Value(bstrPropName, v);

 SysFreeString(bstrPropName);

Anyway, Perl doesn=E2=80=99t have as sophisticated IDispatch integration =
as Jscript does and cannot recognize something that looks like an assignm=
ent to the result of a function call as a property put to the COM object =
in question.  So the Perl guys have this hack workaround which works grea=
t (though it=E2=80=99s not terribly pretty): they implement a method on t=
heir COM objects called =E2=80=9CSetProperty=E2=80=9D:

 # equivalent Perl code:
 $Application->SetProperty('Value', 'x', 4);
 $Response->Write($Application->Value('x'));

Which brings me back to Python.  I haven=E2=80=99t been able to find anyt=
hing similar in Python.  Fortunately, Python=E2=80=99s COM integration ha=
s much more to it than Perl=E2=80=99s, so I can call the IDispatch direct=
ly and do what I want.

 # equivalent Python code:
 o      =3D Application._oleobj_;
 dispId =3D o.GetIDsOfNames('Value');

 # perform the equivalent of Application('x') =3D 4
 o.Invoke(dispId, 0x0, pythoncom.DISPATCH_PROPERTYPUT, 0, 'x', 4);

 Response.Write(Application('x'));

Blech!  Does anyone know a better way?

Being able to store stuff in the application object, by the way, is reall=
y useful for ASP programming (at least the stuff I=E2=80=99m working on).=
  It allows you to maintain a state across your web application from requ=
est to request.  The caveat is that anything you want to store in the App=
lication object has to be able to fit inside a VARIANT.  Futhermore, if t=
he thingy you want to store is an object (like VT_DISPATCH), then it has =
to be free-threaded (I=E2=80=99m not so sure about this restriction).  Th=
is is a bummer, because I would like to store Perl or Python=E2=80=99s ri=
ch data structures in there.

However, I was playing around with Python and noticed something strange. =
 Consider the following ASP script:

 <%@ LANGUAGE=3D"Python" %>
 <%
 import sys;
 if 'x' in dir(sys):
    Response.Write('x in dir %s' % sys.x);
    sys.x =3D sys.x + 1
 else:
    Response.Write('x not in dir');
    sys.x =3D 0
 %>

What happens on my server setup is cool: =E2=80=9Csys.x=E2=80=9D is a cou=
nter of how many times I=E2=80=99ve refreshed the page.  Anyone know what=
=E2=80=99s going on here?  I have a hunch this is just an implementation =
side-effect and not by-design, but it would be really useful.

I=E2=80=99m not subscribed to this list, so please copy me in any replies=
.

Thanks in advance!

Marc MillerGet more from the Web.  FREE MSN Explorer download : http://ex=
plorer.msn.com

------=_NextPart_001_0000_01C108D6.06A69AD0
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

<HTML><BODY STYLE=3D"font:10pt verdana; border:none;"><DIV><FONT face=3D"=
Courier New, Courier, Monospace"><SPAN style=3D"FONT-FAMILY: 'Courier New=
'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-=
language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">D=
o people do serious ASP programming in Python?<SPAN style=3D"mso-spacerun=
: yes">&nbsp; </SPAN>I've recently been doing somewhat-serious ASP progra=
mming in Perl and have started investigating Python as an alternative.<SP=
AN style=3D"mso-spacerun: yes">&nbsp; </SPAN>The lack of thorough documen=
tation and reasonable examples struck me, but that didn't stop me from en=
tering the Perl ASP world :-).<SPAN style=3D"mso-spacerun: yes">&nbsp; </=
SPAN>Anyway, I've got two questions that maybe someone can help me with.<=
/SPAN></FONT></DIV> <DIV><FONT face=3D"Courier New, Courier, Monospace"><=
SPAN style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-fo=
nt-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-langu=
age: EN-US; mso-bidi-language: AR-SA"></SPAN></FONT>&nbsp;</DIV> <DIV><FO=
NT face=3D"Courier New, Courier, Monospace"><SPAN style=3D"FONT-FAMILY: '=
Courier New'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'=
; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-languag=
e: AR-SA"><SPAN style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso=
-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fa=
reast-language: EN-US; mso-bidi-language: AR-SA">The first question deals=
 with assigning to COM object properties which take arguments.<SPAN style=
=3D"mso-spacerun: yes">&nbsp; </SPAN>A very similar question was asked in=
 April by Gregory P. Smith ("assigning vb properties from python via COM"=
).<SPAN style=3D"mso-spacerun: yes">&nbsp; </SPAN>Consider the following =
piece of JScript code:</SPAN></SPAN></FONT></DIV> <DIV><FONT face=3D"Cour=
ier New, Courier, Monospace"><SPAN style=3D"FONT-FAMILY: 'Courier New'; F=
ONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-lang=
uage: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"><SPAN=
 style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-f=
amily: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language:=
 EN-US; mso-bidi-language: AR-SA"></SPAN></SPAN></FONT>&nbsp;</DIV> <DIV>=
<FONT face=3D"Courier New">&nbsp;// example JScript code</FONT></DIV> <DI=
V><FONT face=3D"Courier New"><STRONG>&nbsp;Application('x') =3D 4;</STRON=
G></FONT></DIV> <DIV><FONT face=3D"Courier New">&nbsp;Response.Write(Appl=
ication('x'));</FONT></DIV> <DIV>&nbsp;</DIV> <DIV><FONT face=3D"Courier =
New, Courier, Monospace"><SPAN style=3D"FONT-FAMILY: 'Courier New'; FONT-=
SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language=
: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"><SPAN sty=
le=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-famil=
y: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-=
US; mso-bidi-language: AR-SA"><SPAN style=3D"FONT-FAMILY: 'Courier New'; =
FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-lan=
guage: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">The =
output is "4".<SPAN style=3D"mso-spacerun: yes">&nbsp; </SPAN>This exampl=
e doesn't compile in python-land; you get an error because you're assigni=
ng to the result of a function call.<SPAN style=3D"mso-spacerun: yes">&nb=
sp; </SPAN>I think there was some confusion on the other thread, so let m=
e just expand on what's happening here: JScript is calling the default me=
thod on the application object, "Value", so this is equivalent to the fol=
lowing JScript code:</SPAN></SPAN></SPAN></FONT></DIV> <DIV><FONT face=3D=
"Courier New, Courier, Monospace"><SPAN style=3D"FONT-FAMILY: 'Courier Ne=
w'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi=
-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">=
<SPAN style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-f=
ont-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-lang=
uage: EN-US; mso-bidi-language: AR-SA"><SPAN style=3D"FONT-FAMILY: 'Couri=
er New'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso=
-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR=
-SA"></SPAN></SPAN></SPAN></FONT><FONT face=3D"Courier New, Courier, Mono=
space"><BR> <DIV><FONT face=3D"Courier New">&nbsp;// example JScript code=
</FONT></DIV> <DIV><FONT face=3D"Courier New"><STRONG>&nbsp;Application.V=
alue('x') =3D 4;</STRONG></FONT></DIV> <DIV><FONT face=3D"Courier New">&n=
bsp;Response.Write(Application('x'));</FONT><BR></DIV> <DIV><SPAN style=3D=
"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-family: 'T=
imes New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; m=
so-bidi-language: AR-SA">JScript actually turns the assignment into a sin=
gle COM call which is equivalent to this pseudo-C++ code:</SPAN></DIV> <D=
IV><SPAN style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareas=
t-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-l=
anguage: EN-US; mso-bidi-language: AR-SA"></SPAN>&nbsp;</DIV> <DIV><SPAN =
style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-fa=
mily: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: =
EN-US; mso-bidi-language: AR-SA">&nbsp;// equivalent pseudo-C++ code<BR>&=
nbsp;VARIANT v =3D { 0 };&nbsp;&nbsp; // put =E2=80=9C4=E2=80=9D inside a=
 variant<BR>&nbsp;v.vt&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =3D VT_I4;<BR>&nbsp;=
v.lval&nbsp;&nbsp;&nbsp; =3D 4;</SPAN></DIV> <DIV><SPAN style=3D"FONT-FAM=
ILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New =
Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-l=
anguage: AR-SA"></SPAN>&nbsp;</DIV> <DIV><SPAN style=3D"FONT-FAMILY: 'Cou=
rier New'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; m=
so-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: =
AR-SA">&nbsp;BSTR&nbsp; bstrPropName =3D SysAllocString(=E2=80=9Cx=E2=80=9D=
);</SPAN></DIV> <DIV><SPAN style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE=
: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN=
-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"></SPAN>&nbsp;=
</DIV> <DIV><SPAN style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; m=
so-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-=
fareast-language: EN-US; mso-bidi-language: AR-SA">&nbsp;// assume pAppli=
cation is of type IApplicationObject (see asp.dll)<BR><STRONG>&nbsp;pAppl=
ication-&gt;put_Value(bstrPropName, v);</STRONG></SPAN></DIV> <DIV><SPAN =
style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-fa=
mily: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: =
EN-US; mso-bidi-language: AR-SA"></SPAN>&nbsp;</DIV> <DIV><SPAN style=3D"=
FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Ti=
mes New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; ms=
o-bidi-language: AR-SA">&nbsp;SysFreeString(bstrPropName);<BR></DIV></SPA=
N> <DIV><SPAN style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-f=
areast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fare=
ast-language: EN-US; mso-bidi-language: AR-SA"><SPAN style=3D"FONT-FAMILY=
: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Rom=
an'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-lang=
uage: AR-SA">Anyway, Perl doesn=E2=80=99t have as sophisticated IDispatch=
 integration as Jscript does and cannot recognize something that looks li=
ke an assignment to the result of a function call as a property put to th=
e COM object in question.<SPAN style=3D"mso-spacerun: yes">&nbsp; </SPAN>=
So the Perl guys have this hack workaround which works great (though it=E2=
=80=99s not terribly pretty): they implement a method on their COM object=
s called =E2=80=9CSetProperty=E2=80=9D:</SPAN></SPAN></DIV> <DIV><SPAN st=
yle=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-fami=
ly: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN=
-US; mso-bidi-language: AR-SA"><SPAN style=3D"FONT-FAMILY: 'Courier New';=
 FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-la=
nguage: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"></S=
PAN></SPAN>&nbsp;</DIV> <DIV><SPAN style=3D"FONT-FAMILY: 'Courier New'; F=
ONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-lang=
uage: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"><SPAN=
 style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-f=
amily: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language:=
 EN-US; mso-bidi-language: AR-SA">&nbsp;# equivalent Perl code:<BR>&nbsp;=
$Application-&gt;SetProperty('Value', 'x', 4);<BR>&nbsp;$Response-&gt;Wri=
te($Application-&gt;Value('x'));</SPAN></SPAN></DIV> <DIV><SPAN style=3D"=
FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Ti=
mes New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; ms=
o-bidi-language: AR-SA"><SPAN style=3D"FONT-FAMILY: 'Courier New'; FONT-S=
IZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language:=
 EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"></SPAN></S=
PAN>&nbsp;</DIV> <DIV><SPAN style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZ=
E: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: E=
N-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"><SPAN style=3D=
"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-family: 'T=
imes New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; m=
so-bidi-language: AR-SA"></SPAN></SPAN><SPAN style=3D"FONT-FAMILY: 'Couri=
er New'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso=
-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR=
-SA"><SPAN style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fare=
ast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast=
-language: EN-US; mso-bidi-language: AR-SA"><SPAN style=3D"FONT-FAMILY: '=
Courier New'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'=
; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-languag=
e: AR-SA">Which brings me back to Python.<SPAN style=3D"mso-spacerun: yes=
">&nbsp; </SPAN>I haven=E2=80=99t been able to find anything similar in P=
ython.<SPAN style=3D"mso-spacerun: yes">&nbsp; </SPAN>Fortunately, Python=
=E2=80=99s COM integration has much more to it than Perl=E2=80=99s, so I =
can call the IDispatch directly and do what I want.</SPAN></DIV></SPAN></=
SPAN> <DIV><SPAN style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; ms=
o-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-f=
areast-language: EN-US; mso-bidi-language: AR-SA"></SPAN>&nbsp;</DIV> <DI=
V><SPAN style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast=
-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-la=
nguage: EN-US; mso-bidi-language: AR-SA">&nbsp;# equivalent Python code:<=
BR>&nbsp;o&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =3D Application._oleobj_;<BR>&nb=
sp;dispId =3D o.GetIDsOfNames('Value');</SPAN></DIV> <DIV><SPAN style=3D"=
FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Ti=
mes New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; ms=
o-bidi-language: AR-SA"></SPAN>&nbsp;</DIV> <DIV><SPAN style=3D"FONT-FAMI=
LY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New R=
oman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-la=
nguage: AR-SA">&nbsp;# perform the equivalent of Application('x') =3D 4<B=
R><STRONG>&nbsp;o.Invoke(dispId, 0x0, pythoncom.DISPATCH_PROPERTYPUT, 0, =
'x', 4);</STRONG></SPAN></DIV> <DIV><SPAN style=3D"FONT-FAMILY: 'Courier =
New'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-an=
si-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA=
"></SPAN>&nbsp;</DIV> <DIV><SPAN style=3D"FONT-FAMILY: 'Courier New'; FON=
T-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-langua=
ge: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">&nbsp;R=
esponse.Write(Application('x'));</SPAN></DIV> <DIV>&nbsp;</DIV> <DIV><SPA=
N style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-=
family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language=
: EN-US; mso-bidi-language: AR-SA">Blech!<SPAN style=3D"mso-spacerun: yes=
">&nbsp; </SPAN>Does anyone know a better way?</SPAN></DIV> <DIV><SPAN st=
yle=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-fami=
ly: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN=
-US; mso-bidi-language: AR-SA"></SPAN>&nbsp;</DIV> <DIV><SPAN style=3D"FO=
NT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Time=
s New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-=
bidi-language: AR-SA"><SPAN style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZ=
E: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: E=
N-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">Being able t=
o store stuff in the application object, by the way, is really useful for=
 ASP programming (at least the stuff I=E2=80=99m working on).<SPAN style=3D=
"mso-spacerun: yes">&nbsp; </SPAN>It allows you to maintain a state acros=
s your web application from request to request.<SPAN style=3D"mso-spaceru=
n: yes">&nbsp; </SPAN>The caveat is that anything you want to store in th=
e Application object has to be able to fit inside a VARIANT.<SPAN style=3D=
"mso-spacerun: yes">&nbsp; </SPAN>Futhermore, if the thingy you want to s=
tore is an object (like VT_DISPATCH), then it has to be free-threaded (I=E2=
=80=99m not so sure about this restriction).<SPAN style=3D"mso-spacerun: =
yes">&nbsp; </SPAN>This is a bummer, because I would like to store Perl o=
r Python=E2=80=99s rich data structures in there.</SPAN></SPAN></DIV> <DI=
V><SPAN style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast=
-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-la=
nguage: EN-US; mso-bidi-language: AR-SA"><SPAN style=3D"FONT-FAMILY: 'Cou=
rier New'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; m=
so-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: =
AR-SA"></SPAN></SPAN>&nbsp;</DIV> <DIV><SPAN style=3D"FONT-FAMILY: 'Couri=
er New'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso=
-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR=
-SA"><SPAN style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fare=
ast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast=
-language: EN-US; mso-bidi-language: AR-SA"><SPAN style=3D"FONT-FAMILY: '=
Courier New'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'=
; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-languag=
e: AR-SA">However, I was playing around with Python and noticed something=
 strange.<SPAN style=3D"mso-spacerun: yes">&nbsp; </SPAN>Consider the fol=
lowing ASP script:</SPAN></SPAN></SPAN></DIV> <DIV><SPAN style=3D"FONT-FA=
MILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New=
 Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-=
language: AR-SA"></SPAN>&nbsp;</DIV> <DIV><SPAN style=3D"FONT-FAMILY: 'Co=
urier New'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; =
mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language:=
 AR-SA">&nbsp;&lt;%@ LANGUAGE=3D"Python" %&gt;</SPAN></DIV> <DIV><SPAN st=
yle=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-fami=
ly: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN=
-US; mso-bidi-language: AR-SA">&nbsp;&lt;%<BR>&nbsp;import sys;</SPAN></D=
IV> <DIV><SPAN style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-=
fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-far=
east-language: EN-US; mso-bidi-language: AR-SA">&nbsp;if 'x' in dir(sys):=
<BR>&nbsp; &nbsp; Response.Write('x in dir %s' % sys.x);<BR>&nbsp; &nbsp;=
 sys.x =3D sys.x + 1<BR>&nbsp;else:<BR>&nbsp; &nbsp; Response.Write('x no=
t in dir');<BR>&nbsp; &nbsp; sys.x =3D 0</SPAN></DIV> <DIV><SPAN style=3D=
"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-family: 'T=
imes New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; m=
so-bidi-language: AR-SA">&nbsp;%&gt;</SPAN></DIV> <DIV><SPAN style=3D"FON=
T-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times=
 New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-b=
idi-language: AR-SA"></SPAN>&nbsp;</DIV> <DIV><SPAN style=3D"FONT-FAMILY:=
 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roma=
n'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-langu=
age: AR-SA"><SPAN style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; m=
so-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-=
fareast-language: EN-US; mso-bidi-language: AR-SA">What happens on my ser=
ver setup is cool: =E2=80=9Csys.x=E2=80=9D is a counter of how many times=
 I=E2=80=99ve refreshed the page.<SPAN style=3D"mso-spacerun: yes">&nbsp;=
 </SPAN>Anyone know what=E2=80=99s going on here?<SPAN style=3D"mso-space=
run: yes">&nbsp; </SPAN>I have a hunch this is just an implementation sid=
e-effect and not by-design, but it would be really useful.</SPAN></SPAN><=
/DIV> <DIV><SPAN style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; ms=
o-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-f=
areast-language: EN-US; mso-bidi-language: AR-SA"><SPAN style=3D"FONT-FAM=
ILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New =
Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-l=
anguage: AR-SA"></SPAN></SPAN>&nbsp;</DIV> <DIV><SPAN style=3D"FONT-FAMIL=
Y: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Ro=
man'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-lan=
guage: AR-SA"><SPAN style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt;=
 mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; ms=
o-fareast-language: EN-US; mso-bidi-language: AR-SA"><SPAN style=3D"FONT-=
FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times N=
ew Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bid=
i-language: AR-SA">I=E2=80=99m not subscribed to this list, so please cop=
y me in any replies.</SPAN></SPAN></SPAN></DIV> <DIV><SPAN style=3D"FONT-=
FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times N=
ew Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bid=
i-language: AR-SA"><SPAN style=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: =
10pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-U=
S; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"><SPAN style=3D"=
FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Ti=
mes New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; ms=
o-bidi-language: AR-SA"></SPAN></SPAN></SPAN>&nbsp;</DIV> <DIV><SPAN styl=
e=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-family=
: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-U=
S; mso-bidi-language: AR-SA">Thanks in advance!</SPAN></DIV> <DIV><SPAN s=
tyle=3D"FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-fam=
ily: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: E=
N-US; mso-bidi-language: AR-SA"></SPAN>&nbsp;</DIV> <DIV><SPAN style=3D"F=
ONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Tim=
es New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso=
-bidi-language: AR-SA">Marc Miller</SPAN></DIV> <DIV><SPAN style=3D"FONT-=
FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times N=
ew Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bid=
i-language: AR-SA"><BR>&nbsp;</DIV></SPAN></DIV></FONT></BODY></HTML><br =
clear=3Dall><hr>Get more from the Web.  FREE MSN Explorer download : <a h=
ref=3D'http://explorer.msn.com'>http://explorer.msn.com</a><br></p>

------=_NextPart_001_0000_01C108D6.06A69AD0--