The following test fails:
#!/usr/bin/env python
def f(*args):
"""
>>> t = 1, -1
>>> f(*map(lambda i: lambda: i, t))
[1, -1]
>>> f(*(lambda: i for i in t)) # -> [-1, -1]
[1, -1]
>>> f(*[lambda: i for i in t]) # -> [-1, -1]
[1, -1]
"""
alist = [a() for a in args]
print(alist)
if __name__ == '__...
Hi,
I'm preparing a class on Visual Basic 2005 targeting Visual Basic 6 programmers migrating to the .NET platform.
I would like a word of advice about whether to recommend them to always enable Option Strict or not.
I've worked exclusively with C-style programming languages, mostly Java and C#, so for me explicit casting is something I...
While I was investigating a problem I had with lexical closures in Javascript code, I came along this problem in Python:
flist = []
for i in xrange(3):
def func(x): return x * i
flist.append(func)
for f in flist:
print f(2)
Note that this example mindfully avoids lambda. It prints "4 4 4", which is surprising. I'd expect...
I'm tring to build a library for simplifing late binding calls in C#, and I'm getting trouble tring with reference parameteres. I have the following method to add a parameter used in a method call
public IInvoker AddParameter(ref object value)
{
//List<object> _parameters = new List<object>();
_parameters.Add(val...
For example, how can I run me.test below?
myvar = 'test'
me.myvar
ASP looks for the method "myvar" and doesn't find it. In PHP I could simply say $me->$myvar but ASP's syntax doesn't distinguish between variables and methods. Suggestions?
Closely related to this, is there a method_exists function in ASP Classic?
Thanks in advance!
...
I can do this:
Dim fso As New FileSystemObject
or I can do this:
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
How do I know what string to use for CreateObject? For example, how would I know to use the "Scripting." part of "Scripting.FileSystemObject"? Where do you go to look that up?
...
The Question
My question is: Does C# nativly support late-binding IDispatch?
Pretend i'm trying to automate Office, while being compatible with whatever version the customer has installed.
In the .NET world if you developed with Office 2000 installed, every developer, and every customer, from now until the end of time, is require...
I have a question on C++ double dispatch. In the code below, I want the results from the second set to match the results from the first set.
I don't know the actual type (unless I try dynamic_cast) but I do know that the object inherited from the BaseClass type. What is the most efficient (performance-wise) way to accomplish this?
Aft...
In his definition of OOP, Alan Kay points out he supports "the extreme late-binding of all things". Does his interest in late-binding share the same motivation as people's interest in IoC?
In particular, would it be correct to say that both are motivated by the concept "specify as little as possible, and leave implementation details to ...
I have an event handler for a Textbox as well as for a RichTextBox.
The code is identical, but
In handler #1 i do:
RichTextBox tb = (RichTextBox)sender
In handler #2 accordingly:
TextBox tb = (TextBox)sender
Doing so i can fully manipulate the sending control.
What i want to know is how can i cast the sending object to Textbox or ...
Hello,
I have this piece of code that works very well and gives me the path the user's start menu:
Dim oShell As Object = CreateObject("Shell.Application")
MsgBox(oShell.NameSpace(11).Self.Path)
This obviously uses late binding. Now say I want to do this in C#, or in VB.NET strict mode, neither of which support this kind of s...
I have a COM component that I want to call using late-binding from VB.NET (using the painful Primary Interop Assembly - PIA method)
My IDL signature for the COM method looks like:
HRESULT Send([in]BSTR bstrRequestData,
[out]VARIANT *pvbstrResponseData,
[out]VARIANT *pvnExtCompCode,
[out,retval]int...
I'm reading this book on C# and .NET and I'm learning a bunch of cool stuff. I've read the part where the author talks about dynamically loading an assembly and creating an instance of a type in that assembly.
In AS3, it's possible to do the same kind of stuff, except for one thing : you can ask the compiler to not compile a set of cla...
In VB6, I'm trying to pass a late bound object to another form.
frmMain.vb
Dim x
Set x = CreateObject("MyOwn.Object")
Dim f as frmDialog
Set f = New frmDialog
f.SetMyOwnObject x
frmDialog
Dim y
Public Sub SetMyOwnObject(ByVal paramX As Variant)
Set y = paramX
End Sub
The contents of y are a string containing the type name of the...
I have a data driven mapping application where I need to implement custom functions as plugins. The name of the custom method that I need to execute will also be in the mapping data. I know that I can call the method using the invoke command; but, how can I ensure that each method has the appropriate signature?
...
I guess I do have to release also late bound COM objects.
But how is this done directly?
In my situation I use the following code from C# to get the focused point from Google Earth (simplified):
Type oClassType = Type.GetTypeFromProgID("GoogleEarth.ApplicationGE");
object oGE = Activator.CreateInstance(oClassType);
object oCamera = oGE...
I'd like to access a COM library via late binding.
How can I find out its progID?
Type oClassType = Type.GetTypeFromProgID("THE MISSING PROGID");
...
We are working with an existing native application (most likely written in VB) that loads assemblies and calls methods with "Late Binding." We do NOT have access to its source code.
We want to implement this interface in C#, and have the native application call our C# assembly.
Is this something that's possible?
Is this anything we h...
The following F# code fails because Type.DefaultBinder does not want to bind to the generic Id method. Is there an alternative Binder that would do this?
open System
open System.Reflection
type Foo() =
member this.Id<'T>(x: 'T) : 'T = x //'
typeof<Foo>.InvokeMember (
"F",
BindingFlags.InvokeMethod,
Type.DefaultBinder,...
Hi all,
Just after a little help with late binding.
I am trying to late bind excel and i don't have any issues doing that. It is only when I have more than one instance of excel open where I run into some problems.
I would like to be able to determine what instance of excel to bind to (and the link events etc.). Main reason being I ha...