WSC in python clears method arguments
sholden at holdenweb.com
Thu Nov 8 18:52:53 CET 2001
"T Malcolm" <nt_colonel at hotmail.com> wrote ...
> I'm calling a WSC written in Python from a VBS script that is task
> scheduled. This WSC is a "friendly" interface to the Python ftp
> library. All is well, except for one quirk. When I call methods on
> the WSC, it will clear the variable I pass as an argument.
So the scripting component is an object, and you are creating instances...
> Example vbs client script(where objFTP is an instance of the Python
> strRemotePath = rs.Fields("RemotePath").Value
> 'strRemotePath has a value here
So here you appear to be calling a method of the instance you created...
> 'strRemotePath is now a nullstring, the cwd command has succeeded.
> Python code in WSC (objFTP is an instance of FTP imported from
> def cwd(RemotePath, FTP=objFTP):
But this appears to be a function definition, not a method. Surely cwd()
shouod be defined inside the definition of the class instantiated as objFTP.
Its first argument should be self -- that's how ytou'd expect to [pick up
the object on which the method is being called.
> I had to use the FTP=objFTP as an argument because I couldn't
> reference objFTP in the function from the "global" namespace where it
> resides (another quirk?).
Erm, objFTP shouldn't (and probably doesn't) reside in your Python module's
namespace. It should be created dynamically and referred to as self (method
1st argument) when required.
> Anyway, does anybody have any idea how I can get this thing to quit
> "eating" my variable values?
There's probably something I'm missing here. Have you got a copy of Hammond
and Robinson's "Programming Python on Win32"? Great reference to all this
More information about the Python-list