[python-win32] empty variants

M Shah Din msdin@rpoptions.com
03 Jul 2002 08:31:03 -0700


Hi Jens,

Unfortunately, I cannot change the code.  Its another party's COM
object, and I have to use it.  

Thanks,
Shah


On Wed, 2002-07-03 at 07:27, Jorgensen, Jens wrote:
> Shah,
>  
> I'm not familiar with the actual code but I can easily see how this 
> would happen since a ByRef argument will pass a pointer to a VARIANT 
> so Python would just interpret passing None as passing no pointer. 
> Is it necessary that the function take the VARIANT ByRef? Could it 
> instead take it ByVal and then return the variant? If you did it this 
> way it should work if you pass None.
> 
> 	-----Original Message----- 
> 	From: M Shah Din [mailto:msdin@rpoptions.com] 
> 	Sent: Tue 7/2/2002 6:39 PM 
> 	To: python-win32@python.org 
> 	Cc: 
> 	Subject: [python-win32] empty variants
> 	
> 	
> 
> 	Hi,
> 	
> 	I need to pass an empty variant to a COM objects method but I can't
> 	figure out how to do it.  I asked the same question a while ago, but the
> 	proposed solution did not work.  I have some more details now...
> 	
> 	The COM object has a method that looks like this:
> 	
> 	------------------------------------------------------------------
> 	
> 	Public Sub Foo(ByRef myVariant as Variant, ByRef param1 as String)
> 	
> 	        Dim my_flag as Boolean
> 	
> 	        If IsEmpty(myVariant) Then
> 	                my_flag = True
> 	        Else
> 	            If myVariant Is Nothing Then
> 	                my_flag = True
> 	            Else
> 	                my_flag = False
> 	            End If
> 	        End If
> 	
> 	        If my_flag = True Then
> 	                Set myVariant = CreateObject("some_object")
> 	        End If
> 	
> 	        myVariant.SomeMethod()
> 	
> 	End Sub
> 	
> 	------------------------------------------------------------------
> 	
> 	When I call it from python, the my_flag variable is never True.  If I
> 	pass in None for myVariant, the VB debugger shows it as being Null.  If
> 	I pass in pythoncom.Empty, the VB debugger shows it as being Missing.
> 	It works fine if I call it from a VB method and just dim the variant
> 	without setting it to anything.  How can I pass an empty or nothing
> 	variant from python?
> 	
> 	I am using ActiveState ActivePython 2.2 on Win2k.
> 	
> 	Thanks,
> 	Shah
> 	
> 	
> 	
> 	
> 	_______________________________________________
> 	Python-win32 mailing list
> 	Python-win32@python.org
> 	http://mail.python.org/mailman/listinfo/python-win32
> 	
>