Re: [IronPython] New to Ironpython. Want to glue DLL with Python code

2007-08-05 Thread Hugo González Monteverde
Howard R. Hansen wrote:
> What type of compiler was used to write the  dll?  Is it a .net dll or 
> some other type like unmanaged
>  C++? 

Hi Howard (and Michael),

The DLL is a proprietary one from the  GrFinger SDK package 
(http://www.griaule.com/page/en-us/grfinger_fingerprint_sdk) so I don't 
have that information. There are examples of use also for VB.NET and 
C++.NET. So I would guess the DLL would be a .NET dll, does this make sense?

The example code they provide in C# does this:

//
using GrFingerXLib
using System
...
...
//and then is used as

// Extract a fingerprint template from current image
public int ExtractTemplate()
{
int result;

// set current buffer size for the extract template
_tpt._size = (int)GRConstants.GR_MAX_SIZE_TEMPLATE;
result = (int)_grfingerx.Extract(
ref _raw.img, _raw.width, _raw.height, _raw.Res,
ref _tpt._tpt,ref _tpt._size,
(int)GRConstants.GR_DEFAULT_CONTEXT);
// if error, set template size to 0
if (result < 0)
{
// Result < 0 => extraction problem
_tpt._size = 0;
}
return result;
}

/

I was hoping that a DLL named GrFingerXLib would be available somewhere 
in my system (after the installation of the SDK) but there is none. 
There are several different files:  GrFinger.dll  and GrFingerX.dll

This is what I (naively)  attempted:

C:\IronPython-1.1>ipy
IronPython 1.1 (1.1) on .NET 2.0.50727.832
Copyright (c) Microsoft Corporation. All rights reserved.
 >>> import GrFinger
Traceback (most recent call last):
   File , line 0, in ##9
   File , line 0, in __import__##4
ImportError: No module named GrFinger
 >>> import GrFingerX
Traceback (most recent call last):
   File , line 0, in ##10
   File , line 0, in __import__##4
ImportError: No module named GrFingerX
 >>> import GrFingerXLib
Traceback (most recent call last):
   File , line 0, in ##11
   File , line 0, in __import__##4
ImportError: No module named GrFingerXLib
 >>>

Hope that is useful. I can make the files available privately if that helps.

Hugo
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


[IronPython] C# and IronPython

2007-08-05 Thread sms rku
I am very new to Python and IronPython.

Could you please let me know if it is possible to

Make my application [.exe] that has a static Main method and 3 other public
methods defined in a class to be accessed from IronPython script?

i.e, Will I be able to create instance of the class from IronPython script?
  Will I be able to call the public methods from the script?

and also, is it possible to call the main function from the script?   [
i.e run my application]

If yes, could you please tell me how it can be done?

Thanks in advance
sms
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] New to Ironpython. Want to glue DLL with Python code

2007-08-05 Thread Howard R. Hansen
What type of compiler was used to write the  dll?  Is it a .net dll or 
some other type like unmanaged
 C++? 

Howard

Hugo González Monteverde wrote:
> Hi all,
>
> I'm new to IronPython, thought I've been using CPython for two years now.
>
> I am now developing a project using a library for processing Biometrics 
> (fingerprint recognition) and would like to use Python to invoke the 
> functions in the DLL. The DLL comes with C# examples, so I'm assuming 
> here that I could use it with IronPython.
>
> What I've tried so far:
>
> Using ctypes: the dll has a a C++ interface, so using ctypes is a 
> torture, functions are only imported ordinally, and no names or anything 
> is available. From here I thought IronPython would be better.
>
> using IronPython: Tried to directly import the classes in the DLL, this 
> did not work. I have read a bit on LoadAssembly, but I'm not sure how it 
> works. SO far I've only been able to "import System" from IronPython, 
> but pretty much nothing else can be imported. There is a full app in C# 
> include with the software.
>
> I'm using Windows XP with the latest ironpython.
>
> I'm really beginning here, so the question would be: how do I import 
> classes and functions from a DLL what I know is accessible from a C# 
> application, using IronPython?
>
> Thanks for any advice or direction,
>
> Hugo G.
>
> ___
> Users mailing list
> Users@lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>   

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] New to Ironpython. Want to glue DLL with Python code

2007-08-05 Thread Michael Foord
Hugo González Monteverde wrote:
> [snip..]
>
> I'm really beginning here, so the question would be: how do I import 
> classes and functions from a DLL what I know is accessible from a C# 
> application, using IronPython?
>
> Thanks for any advice or direction,
>   
Could you show an example of how it is accessed from C#? Then perhaps we 
can show you equivalent IronPython.

All the best,


Michael Foord
http://www.ironpython.info/

> Hugo G.
>
> ___
> Users mailing list
> Users@lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>   

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


[IronPython] New to Ironpython. Want to glue DLL with Python code

2007-08-05 Thread Hugo González Monteverde
Hi all,

I'm new to IronPython, thought I've been using CPython for two years now.

I am now developing a project using a library for processing Biometrics 
(fingerprint recognition) and would like to use Python to invoke the 
functions in the DLL. The DLL comes with C# examples, so I'm assuming 
here that I could use it with IronPython.

What I've tried so far:

Using ctypes: the dll has a a C++ interface, so using ctypes is a 
torture, functions are only imported ordinally, and no names or anything 
is available. From here I thought IronPython would be better.

using IronPython: Tried to directly import the classes in the DLL, this 
did not work. I have read a bit on LoadAssembly, but I'm not sure how it 
works. SO far I've only been able to "import System" from IronPython, 
but pretty much nothing else can be imported. There is a full app in C# 
include with the software.

I'm using Windows XP with the latest ironpython.

I'm really beginning here, so the question would be: how do I import 
classes and functions from a DLL what I know is accessible from a C# 
application, using IronPython?

Thanks for any advice or direction,

Hugo G.

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] .NET can see Python classes?

2007-08-05 Thread Michael Foord
Bryan wrote:
> On 8/5/07, Michael Foord <[EMAIL PROTECTED]> wrote:
>   
>> Here is a full example:
>> [snip...]
>> 
>
> this is great news.  this is very helpful... thanks.  i assume there
> is another Execute method that you can pass in a path to file or take
> a file object so we don't have to write the code in a C# string. 

I believe there is an ExecuteFile method but you should check the docs.

>  what
> i would like to do is create the skeleton of C# web services, then
> have it call out to python code.  what you just showed here is that
> this is definitely possible.  also, i see that your Test was a class
> and not a pure interface.  i hope this will work with pure interfaces
> too.
>   

I'm sure it will. I'm not sure of the exact semantics though. I know 
that I have created Python classes that inherit from .NET interfaces.

Alternatively you could create an abstract C# class that implements the 
interface and inherit from that.

If it does work, posting an example would be great.

Michael
http://www.ironpython.info/

>
> bryan
> ___
> Users mailing list
> Users@lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>   

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] .NET can see Python classes?

2007-08-05 Thread Bryan
On 8/5/07, Michael Foord <[EMAIL PROTECTED]> wrote:
> Here is a full example:
>
> using System;
> using IronPython.Hosting;
> using IronPython.Runtime.Types;
> using IronPython.Runtime.Operations;
>
> namespace TestPythonConsole
> {
> class Program
> {
> static void Main()
> {
> string code = "import
> clr\r\nclr.AddReference('TestPythonConsole')\r\nfrom TestPythonConsole
> import Test\r\nclass X(Test):\r\n def test(self):\r\nreturn
> 'hello'\r\n\r\n";
> PythonEngine engine = new PythonEngine();
> EngineModule module = engine.CreateModule();
> engine.DefaultModule = module;
> engine.Execute(code);
> UserType ptype = module.Globals["X"] as UserType;
> Test obj = Ops.Call(ptype) as Test;
> Console.WriteLine(obj.test());
> }
> }
>
> public class Test
> {
> virtual public string test()
> {
> return "goodbye";
> }
> }
>
> }
>
> Michael Foord

this is great news.  this is very helpful... thanks.  i assume there
is another Execute method that you can pass in a path to file or take
a file object so we don't have to write the code in a C# string.  what
i would like to do is create the skeleton of C# web services, then
have it call out to python code.  what you just showed here is that
this is definitely possible.  also, i see that your Test was a class
and not a pure interface.  i hope this will work with pure interfaces
too.


bryan
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Compiler error for invalid field access

2007-08-05 Thread Ori - Gmail
Well yes, *somewhere*, but there is a big difference between writing the
code and executing it.
It is not easy to create and manage the context in my case

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Michael Foord
Sent: א 05 אוגוסט 2007 23:11
To: Discussion of IronPython
Subject: Re: [IronPython] Compiler error for invalid field access

Ori wrote:
> Executing the code to know if there is a problem or not is not what I wish
> for. I really can't do it because in my case the context does not exist.
> I will try to create a 'fake' context in order to run the code, but I'm
not
> sure it is a good idea..
>
>   

I presume you are executing the code *somewhere*. What about catching 
the error there? (Or creating a 'safe execution' method that does the 
error trapping and routing all calls through that?)

Michael Foord
http://www.ironpython.info/

> Chip Norkus wrote:
>   
>> On Sun Aug 05, 2007; 12:51PM -0700, Ori wrote:
>> 
>>> Hello,
>>>
>>> I'm using the following code to compile python code:
>>>
>>> SystemState state = new SystemState();
>>> MyCompilerSink sink = new MyCompilerSink();
>>> CompilerContext context = new CompilerContext(string.Empty, sink);
>>> Parser parser = Parser.FromString(state, context, "my code");
>>> parser.ParseFileInput();
>>>
>>> it works find for finding syntax mistakes - but I also wan to know about
>>> invalid property names / method names. If for example the code uses the
>>> expression 'self.Name' I would like to see a compilation error if the
>>> object
>>> does not have a 'Name' property.
>>>
>>>   
>> Because objects are mutable Python by its nature does not resolve
>> member/property references until they occur within the code.  Consider
>> the following example (which is valid functional Python):
>>
>> class foo(object):
>> setup = False
>>
>> f = foo()
>>
>> def bar(f):
>> if f.setup:
>> f.baz = "hi"
>> print f.baz
>> else:
>> f.setup = True
>> print "setup"
>>
>> bar(f)
>> bar(f)
>> 
>> 
>>
>> 
>>> Is there a way to do it?
>>>
>>> Thanks,
>>> Ori
>>> -- 
>>> View this message in context:
>>>
http://www.nabble.com/Compiler-error-for-invalid-field-access-tf4220967.html
#a12007623
>>> Sent from the IronPython mailing list archive at Nabble.com.
>>>
>>> ___
>>> Users mailing list
>>> Users@lists.ironpython.com
>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>>>
>>>   
>> -chip
>> --
>> personal: chip norkus; irc: wd;   [EMAIL PROTECTED]
>> info: finger [EMAIL PROTECTED] for plan or keys;  http://telekinesis.org
>> ___
>> Users mailing list
>> Users@lists.ironpython.com
>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>>
>>
>> 
>
>   

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Compiler error for invalid field access

2007-08-05 Thread Michael Foord
Ori wrote:
> Executing the code to know if there is a problem or not is not what I wish
> for. I really can't do it because in my case the context does not exist.
> I will try to create a 'fake' context in order to run the code, but I'm not
> sure it is a good idea..
>
>   

I presume you are executing the code *somewhere*. What about catching 
the error there? (Or creating a 'safe execution' method that does the 
error trapping and routing all calls through that?)

Michael Foord
http://www.ironpython.info/

> Chip Norkus wrote:
>   
>> On Sun Aug 05, 2007; 12:51PM -0700, Ori wrote:
>> 
>>> Hello,
>>>
>>> I'm using the following code to compile python code:
>>>
>>> SystemState state = new SystemState();
>>> MyCompilerSink sink = new MyCompilerSink();
>>> CompilerContext context = new CompilerContext(string.Empty, sink);
>>> Parser parser = Parser.FromString(state, context, "my code");
>>> parser.ParseFileInput();
>>>
>>> it works find for finding syntax mistakes - but I also wan to know about
>>> invalid property names / method names. If for example the code uses the
>>> expression 'self.Name' I would like to see a compilation error if the
>>> object
>>> does not have a 'Name' property.
>>>
>>>   
>> Because objects are mutable Python by its nature does not resolve
>> member/property references until they occur within the code.  Consider
>> the following example (which is valid functional Python):
>>
>> class foo(object):
>> setup = False
>>
>> f = foo()
>>
>> def bar(f):
>> if f.setup:
>> f.baz = "hi"
>> print f.baz
>> else:
>> f.setup = True
>> print "setup"
>>
>> bar(f)
>> bar(f)
>> 
>> 
>>
>> 
>>> Is there a way to do it?
>>>
>>> Thanks,
>>> Ori
>>> -- 
>>> View this message in context:
>>> http://www.nabble.com/Compiler-error-for-invalid-field-access-tf4220967.html#a12007623
>>> Sent from the IronPython mailing list archive at Nabble.com.
>>>
>>> ___
>>> Users mailing list
>>> Users@lists.ironpython.com
>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>>>
>>>   
>> -chip
>> --
>> personal: chip norkus; irc: wd;   [EMAIL PROTECTED]
>> info: finger [EMAIL PROTECTED] for plan or keys;  http://telekinesis.org
>> ___
>> Users mailing list
>> Users@lists.ironpython.com
>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>>
>>
>> 
>
>   

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Compiler error for invalid field access

2007-08-05 Thread Ori

Executing the code to know if there is a problem or not is not what I wish
for. I really can't do it because in my case the context does not exist.
I will try to create a 'fake' context in order to run the code, but I'm not
sure it is a good idea..


Chip Norkus wrote:
> 
> On Sun Aug 05, 2007; 12:51PM -0700, Ori wrote:
>> 
>> Hello,
>> 
>> I'm using the following code to compile python code:
>> 
>> SystemState state = new SystemState();
>> MyCompilerSink sink = new MyCompilerSink();
>> CompilerContext context = new CompilerContext(string.Empty, sink);
>> Parser parser = Parser.FromString(state, context, "my code");
>> parser.ParseFileInput();
>> 
>> it works find for finding syntax mistakes - but I also wan to know about
>> invalid property names / method names. If for example the code uses the
>> expression 'self.Name' I would like to see a compilation error if the
>> object
>> does not have a 'Name' property.
>> 
> 
> Because objects are mutable Python by its nature does not resolve
> member/property references until they occur within the code.  Consider
> the following example (which is valid functional Python):
> 
> class foo(object):
> setup = False
> 
> f = foo()
> 
> def bar(f):
> if f.setup:
> f.baz = "hi"
> print f.baz
> else:
> f.setup = True
> print "setup"
> 
> bar(f)
> bar(f)
> 
> 
> 
>> Is there a way to do it?
>> 
>> Thanks,
>> Ori
>> -- 
>> View this message in context:
>> http://www.nabble.com/Compiler-error-for-invalid-field-access-tf4220967.html#a12007623
>> Sent from the IronPython mailing list archive at Nabble.com.
>> 
>> ___
>> Users mailing list
>> Users@lists.ironpython.com
>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>> 
> -chip
> --
> personal: chip norkus; irc: wd;   [EMAIL PROTECTED]
> info: finger [EMAIL PROTECTED] for plan or keys;  http://telekinesis.org
> ___
> Users mailing list
> Users@lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Compiler-error-for-invalid-field-access-tf4220967.html#a12007689
Sent from the IronPython mailing list archive at Nabble.com.

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Compiler error for invalid field access

2007-08-05 Thread Chip Norkus
On Sun Aug 05, 2007; 12:51PM -0700, Ori wrote:
> 
> Hello,
> 
> I'm using the following code to compile python code:
> 
> SystemState state = new SystemState();
> MyCompilerSink sink = new MyCompilerSink();
> CompilerContext context = new CompilerContext(string.Empty, sink);
> Parser parser = Parser.FromString(state, context, "my code");
> parser.ParseFileInput();
> 
> it works find for finding syntax mistakes - but I also wan to know about
> invalid property names / method names. If for example the code uses the
> expression 'self.Name' I would like to see a compilation error if the object
> does not have a 'Name' property.
> 

Because objects are mutable Python by its nature does not resolve
member/property references until they occur within the code.  Consider
the following example (which is valid functional Python):

class foo(object):
setup = False

f = foo()

def bar(f):
if f.setup:
f.baz = "hi"
print f.baz
else:
f.setup = True
print "setup"

bar(f)
bar(f)



> Is there a way to do it?
> 
> Thanks,
> Ori
> -- 
> View this message in context: 
> http://www.nabble.com/Compiler-error-for-invalid-field-access-tf4220967.html#a12007623
> Sent from the IronPython mailing list archive at Nabble.com.
> 
> ___
> Users mailing list
> Users@lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> 
-chip
--
personal: chip norkus; irc: wd;   [EMAIL PROTECTED]
info: finger [EMAIL PROTECTED] for plan or keys;  http://telekinesis.org
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Compiler error for invalid field access

2007-08-05 Thread Michael Foord
Ori wrote:
> Hello,
>
> I'm using the following code to compile python code:
>
> SystemState state = new SystemState();
> MyCompilerSink sink = new MyCompilerSink();
> CompilerContext context = new CompilerContext(string.Empty, sink);
> Parser parser = Parser.FromString(state, context, "my code");
> parser.ParseFileInput();
>
> it works find for finding syntax mistakes - but I also wan to know about
> invalid property names / method names. If for example the code uses the
> expression 'self.Name' I would like to see a compilation error if the object
> does not have a 'Name' property.
>
> Is there a way to do it?
>   

Python does not generate 'compile' errors for these sorts of problems. 
Python is dynamically typed, so it doesn't know about the type of 
objects at compile time - instead errors will be generated at runtime.

As well as catching errors at compilation (syntax errors) you will also 
need to catch potential errors where these objects are used. This is the 
joy and the pain of using a dynamically typed language.

All the best,


Michael Foord
http://www.ironpython.info/
> Thanks,
> Ori
>   

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


[IronPython] Compiler error for invalid field access

2007-08-05 Thread Ori

Hello,

I'm using the following code to compile python code:

SystemState state = new SystemState();
MyCompilerSink sink = new MyCompilerSink();
CompilerContext context = new CompilerContext(string.Empty, sink);
Parser parser = Parser.FromString(state, context, "my code");
parser.ParseFileInput();

it works find for finding syntax mistakes - but I also wan to know about
invalid property names / method names. If for example the code uses the
expression 'self.Name' I would like to see a compilation error if the object
does not have a 'Name' property.

Is there a way to do it?

Thanks,
Ori
-- 
View this message in context: 
http://www.nabble.com/Compiler-error-for-invalid-field-access-tf4220967.html#a12007623
Sent from the IronPython mailing list archive at Nabble.com.

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] .NET can see Python classes?

2007-08-05 Thread Michael Foord
Ori wrote:
> you can try the following code:
>
> PythonEngine engine = new PythonEngine();
> EngineModule module = engine.CreateModule();
> engine.Execute(handleCode(code, def), module); # code contains definition
> for python class 'PyClass'
> UserType ptype = module.Globals["PyClass"] as UserType;
> object obj = Ops.Call(ptype);
>   
Here is a full example:

using System;
using IronPython.Hosting;
using IronPython.Runtime.Types;
using IronPython.Runtime.Operations;

namespace TestPythonConsole
{
class Program
{
static void Main()
{
string code = "import 
clr\r\nclr.AddReference('TestPythonConsole')\r\nfrom TestPythonConsole 
import Test\r\nclass X(Test):\r\n def test(self):\r\nreturn 
'hello'\r\n\r\n";
PythonEngine engine = new PythonEngine();
EngineModule module = engine.CreateModule();
engine.DefaultModule = module;
engine.Execute(code);
UserType ptype = module.Globals["X"] as UserType;
Test obj = Ops.Call(ptype) as Test;
Console.WriteLine(obj.test());
}
}

public class Test
{
virtual public string test()
{
return "goodbye";
}
}

}

The Python code imports 'Test' (it has to add the right reference to the 
assembly first). It then subclasses 'Test' in a class called X.

The class we pull out of the Python engine globals is called and the 
result cast to Test.

Calling the method 'test' calls the subclass rather than the parent class.

I hope that helps.

Michael Foord
http://www.ironpython.info/


>
> Darren Govoni-2 wrote:
>   
>> Hi,
>>   Can .NET see python defined classes or objects? I define a class in
>> Python
>> but one of my .NET classes tries to find it via reflection and it cannot.
>> I saw a post about this that is over a year old saying it was not then
>> supported.
>>
>> Could this possible in IP 2.0?
>>
>> thank you,
>> D
>> ___
>> Users mailing list
>> Users@lists.ironpython.com
>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>>
>>
>> 
>
>   

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] .NET can see Python classes?

2007-08-05 Thread Curt Hagenlocher
On 8/5/07, Bryan <[EMAIL PROTECTED]> wrote:
>
>
> i to would like to do this.  i don't understand a part of this.  i
> understand creating a CLR interface and i understand creating a python
> file that has a class that derives from the CLR interface.  but how
> does the CLR code instantiate the derived class and access the Python
> code through the interface?  where does this instance come from?


You would have to interact directly with the IronPython engine from the "CLR
code" in order to get an instance of the class.  Something like the code
that Ori posted earlier in the thread would work for that.

--
Curt Hagenlocher
[EMAIL PROTECTED]
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] .NET can see Python classes?

2007-08-05 Thread Bryan
On 8/5/07, Curt Hagenlocher <[EMAIL PROTECTED]> wrote:
> On 8/4/07, Darren Govoni <[EMAIL PROTECTED] > wrote:
>
> The fundamental issue here is that Python classes don't follow the same
> semantics as CLR classes.  They are, for instance, mutable after
> construction in ways that CLR classes are not.  In order to expose a Python
> class directly to the CLR, it would have to be "frozen" in some manner, and
> you might prefer to be able to specify the types of the parameters instead
> of dealing with everything as "object".  This would require some sort of
> non-Python syntax to accomplish.  Fortunately, there already is such a
> thing: a CLR interface.  Define an interface in an external assembly and you
> can derive from it in Python.  Your CLR classes can then access the Python
> code through the interface.
>
> --
> Curt Hagenlocher
> [EMAIL PROTECTED]

hi curt,

i to would like to do this.  i don't understand a part of this.  i
understand creating a CLR interface and i understand creating a python
file that has a class that derives from the CLR interface.  but how
does the CLR code instantiate the derived class and access the Python
code through the interface?  where does this instance come from?

thanks,

bryan
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] .NET can see Python classes?

2007-08-05 Thread John J Lee
On Sun, 5 Aug 2007, Curt Hagenlocher wrote:
> On 8/4/07, Darren Govoni <[EMAIL PROTECTED]> wrote:
[...]
> construction in ways that CLR classes are not.  In order to expose a Python
> class directly to the CLR, it would have to be "frozen" in some manner, and

A metaclass could achieve that.


> you might prefer to be able to specify the types of the parameters instead
> of dealing with everything as "object".  This would require some sort of
> non-Python syntax to accomplish.  Fortunately, there already is such a

Maybe in the future this will be used?

http://www.python.org/dev/peps/pep-3107/


John

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] .NET can see Python classes?

2007-08-05 Thread Darren Govoni
I see. Currently, my python class extends a CLR class, but the python class is 
not resolvable from CLR. I want a CLR persistence engine
to be able to reflect on the python class as if it were a CLR class, but it 
says it cannot find the MyPython class created in my python script.
I guess my python classes also do not fall under a given CLR namespace either?

Now, if it were a pure interface implementation, I suppose its not possible to 
pass an instance of MyPython back to CLR to process as a normal
class instance (including reflection)?

thanks. I really like IronPython and it works great embedded in my app.

Darren
  - Original Message - 
  From: Curt Hagenlocher 
  To: Discussion of IronPython 
  Sent: Sunday, August 05, 2007 12:31 PM
  Subject: Re: [IronPython] .NET can see Python classes?


  On 8/4/07, Darren Govoni <[EMAIL PROTECTED] > wrote: 
  Can .NET see python defined classes or objects? I define a class in Python
but one of my .NET classes tries to find it via reflection and it cannot.
I saw a post about this that is over a year old saying it was not then 
supported.

  The fundamental issue here is that Python classes don't follow the same 
semantics as CLR classes.  They are, for instance, mutable after construction 
in ways that CLR classes are not.  In order to expose a Python class directly 
to the CLR, it would have to be "frozen" in some manner, and you might prefer 
to be able to specify the types of the parameters instead of dealing with 
everything as "object".  This would require some sort of non-Python syntax to 
accomplish.  Fortunately, there already is such a thing: a CLR interface.  
Define an interface in an external assembly and you can derive from it in 
Python.  Your CLR classes can then access the Python code through the 
interface. 

  --
  Curt Hagenlocher
  [EMAIL PROTECTED]


--


  ___
  Users mailing list
  Users@lists.ironpython.com
  http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] .NET can see Python classes?

2007-08-05 Thread Curt Hagenlocher
On 8/4/07, Darren Govoni <[EMAIL PROTECTED]> wrote:
>
>Can .NET see python defined classes or objects? I define a class in
> Python
> but one of my .NET classes tries to find it via reflection and it cannot.
> I saw a post about this that is over a year old saying it was not then
> supported.
>

The fundamental issue here is that Python classes don't follow the same
semantics as CLR classes.  They are, for instance, mutable after
construction in ways that CLR classes are not.  In order to expose a Python
class directly to the CLR, it would have to be "frozen" in some manner, and
you might prefer to be able to specify the types of the parameters instead
of dealing with everything as "object".  This would require some sort of
non-Python syntax to accomplish.  Fortunately, there already is such a
thing: a CLR interface.  Define an interface in an external assembly and you
can derive from it in Python.  Your CLR classes can then access the Python
code through the interface.

--
Curt Hagenlocher
[EMAIL PROTECTED]
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com