Problem with using PythonWin and ActiveX COM Object

Alex Martelli aleaxit at yahoo.com
Fri Oct 6 07:19:54 EDT 2000


<kalab at my-deja.com> wrote in message news:8rk9ig$u9g$1 at nnrp1.deja.com...
> In article <8ri8ba02lfe at news1.newsguy.com>,
>   "Alex Martelli" <aleaxit at yahoo.com> wrote:
> > The behaviour of any Python function is just like that of "thebyval":
> > after a sequence such as
> >     a=23
> >     b=a
> >     thepythonfunction(a)
>
> it depends if the argument is mutable or not:

No it isn't.  If the Visual Basic function is rewritten so that
the [in] (aka ByVal) argument it takes is an array, then it, too,
can change the CONTENTS of the array.  So, equivalence still holds.

Whether a Python function can change the contents of an argument
it's passed is indeed dependent on whether that argument is of
a mutable object-type.  But that is another issue, different from
the [in] vs [in,out], and the ByVal vs ByRef, argument-passing.

> def change(a):
>     a[0] = 24
> a=[23]
> b=a
> print a, b
> change(a)
> print a, b
>
> Output:
> [23] [23]
> [24] [24]

See?  Still identical.


> > it MUST, always, be the case that a and b are still identical, no
> > matter how "thepythonfunction" is written (well... one could play
> > dirty tricks to find and alter the caller's namespace, maybe, but
> > I wouldn't recommend it!-).
>
> You are right - a and b must always be identical since they are both
> references.

Yep -- I phrased it carefully!-)


Alex






More information about the Python-list mailing list