From lance23runner at yahoo.com Sat Dec 8 09:09:24 2007 From: lance23runner at yahoo.com (alex omoto) Date: Sat, 8 Dec 2007 00:09:24 -0800 (PST) Subject: [Python.NET] Accessing class interface with private methods Message-ID: <123772.15900.qm@web52608.mail.re2.yahoo.com> Hi, I am having trouble using Python.NET in accessing class interface methods that are declared private. As an example, Public Interface Iface Property Func() As Boolean End Interface Public Class Foo Implements Iface Private Function Func() As Boolean Return True End Function Public ReadOnly Property IFACE() As Iface Get Return Me End Get End Property End Class Then using Python 2.5 with Python.Net 2.0 alpha 2, I cannot access the method. Is this supported? import clr import Foo f = Foo() f.IFACE # OK f.IFACE.Func() # results in Attribute error Thanks, Alex --------------------------------- Never miss a thing. Make Yahoo your homepage. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20071208/4360dcca/attachment.htm From lance23runner at yahoo.com Sat Dec 8 22:40:19 2007 From: lance23runner at yahoo.com (alex omoto) Date: Sat, 8 Dec 2007 13:40:19 -0800 (PST) Subject: [Python.NET] Structure as argument Message-ID: <114065.20588.qm@web52601.mail.re2.yahoo.com> Hi again, I am basically trying to integrate some python code with already built VB code. I'd prefer not to have to change VB code, but here are the things i noticed... (1) All VB optional arguments must be defined when calling them in Python.Net. (2) I have created a function with a structure as the argument. Public Structure SomeStruct Public dVal As Double End Structure Public Class Class1 ... Public Function test(ByRef arg As SomeStruct) As Boolean return True End Function End Class Using Python.Net, I can create the class, then the struct and call the function with the struct as the argument. I get the following error: System.ArgumentException: Object of type 'System.RuntimeType' cannot be converted to type 'SomeStruct&' Thanks, Alex --------------------------------- Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20071208/f661c4b1/attachment.htm From hsu.feihong at yahoo.com Sun Dec 9 15:54:23 2007 From: hsu.feihong at yahoo.com (Feihong Hsu) Date: Sun, 9 Dec 2007 06:54:23 -0800 (PST) Subject: [Python.NET] Accessing class interface with private methods In-Reply-To: <123772.15900.qm@web52608.mail.re2.yahoo.com> Message-ID: <93727.68378.qm@web34805.mail.mud.yahoo.com> This is not supported. You can't access private methods in C# or VB.NET either, so why should Python.NET be able to access them? But one thing to note is that you CAN access protected methods directly in Pyhon.NET (you don't have to make a subclass to use a protected method). - Feihong alex omoto wrote: Hi, I am having trouble using Python.NET in accessing class interface methods that are declared private. As an example, Public Interface Iface Property Func() As Boolean End Interface Public Class Foo Implements Iface Private Function Func() As Boolean Return True End Function Public ReadOnly Property IFACE() As Iface Get Return Me End Get End Property End Class Then using Python 2.5 with Python.Net 2.0 alpha 2, I cannot access the method. Is this supported? import clr import Foo f = Foo() f.IFACE # OK f.IFACE.Func() # results in Attribute error Thanks, Alex --------------------------------- Never miss a thing. Make Yahoo your homepage. _________________________________________________ Python.NET mailing list - PythonDotNet at python.org http://mail.python.org/mailman/listinfo/pythondotnet --------------------------------- Looking for last minute shopping deals? Find them fast with Yahoo! Search. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20071209/c8fb2bc6/attachment.htm From wickardt at xs4all.nl Tue Dec 11 20:23:16 2007 From: wickardt at xs4all.nl (Tijs Wickardt) Date: Tue, 11 Dec 2007 20:23:16 +0100 (CET) Subject: [Python.NET] Accessing class interface with private methods Message-ID: <9207.86.84.134.179.1197400996.squirrel@webmail.xs4all.nl> Actually, there is a way to access private members in C#. You can use System.Reflection to modify access directives. Since you can't access private members from Python .net, you could write a seperate C# module that unhides private members and exposes them as public. You could then call those public methods from Python for .NET. Cumbersome, but should work. Kind regards, Tijs Feihong Hsu hsu.feihong at yahoo.com Sun Dec 9 15:54:23 CET 2007 Previous message: [Python.NET] Accessing class interface with private methods Next message: [Python.NET] Structure as argument Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] -------------------------------------------------------------------------------- This is not supported. You can't access private methods in C# or VB.NET either, so why should Python.NET be able to access them? But one thing to note is that you CAN access protected methods directly in Pyhon.NET (you don't have to make a subclass to use a protected method). - Feihong alex omoto wrote: Hi, I am having trouble using Python.NET in accessing class interface methods that are declared private. As an example, Public Interface Iface Property Func() As Boolean End Interface Public Class Foo Implements Iface Private Function Func() As Boolean Return True End Function Public ReadOnly Property IFACE() As Iface Get Return Me End Get End Property End Class Then using Python 2.5 with Python.Net 2.0 alpha 2, I cannot access the method. Is this supported? import clr import Foo f = Foo() f.IFACE # OK f.IFACE.Func() # results in Attribute error Thanks, Alex From brian.lloyd at revolutionhealth.com Tue Dec 11 20:40:05 2007 From: brian.lloyd at revolutionhealth.com (Brian Lloyd) Date: Tue, 11 Dec 2007 14:40:05 -0500 Subject: [Python.NET] Accessing class interface with private methods In-Reply-To: <9207.86.84.134.179.1197400996.squirrel@webmail.xs4all.nl> Message-ID: Better (or worse) yet, you can just use System.Reflection via python to get at what you need ;) On 12/11/07 2:23 PM, "Tijs Wickardt" wrote: > Actually, there is a way to access private members in C#. > You can use System.Reflection to modify access directives. > > Since you can't access private members from Python .net, you could write a > seperate C# module that unhides private members and exposes them as > public. > You could then call those public methods from Python for .NET. > > Cumbersome, but should work. > > Kind regards, Tijs > > > > Feihong Hsu hsu.feihong at yahoo.com > Sun Dec 9 15:54:23 CET 2007 > > Previous message: [Python.NET] Accessing class interface with private methods > Next message: [Python.NET] Structure as argument > Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] > > ------------------------------------------------------------------------------ > -- > > This is not supported. You can't access private methods in C# or VB.NET > either, so why should Python.NET be able to access them? But one thing to > note is that you CAN access protected methods directly in Pyhon.NET (you > don't have to make a subclass to use a protected method). > > - Feihong > > alex omoto wrote: Hi, > > I am having trouble using Python.NET in accessing class interface methods > that are declared private. As an example, > > Public Interface Iface > Property Func() As Boolean > End Interface > > Public Class Foo > Implements Iface > > Private Function Func() As Boolean > Return True > End Function > > Public ReadOnly Property IFACE() As Iface > Get > Return Me > End Get > End Property > End Class > > Then using Python 2.5 with Python.Net 2.0 alpha 2, I cannot access the > method. Is this supported? > > import clr > import Foo > f = Foo() > f.IFACE # OK > f.IFACE.Func() # results in Attribute error > > > Thanks, > Alex > > > > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet -------------------------- Brian Lloyd brian.lloyd at revolutionhealth.com From wickardt at xs4all.nl Tue Dec 11 21:30:30 2007 From: wickardt at xs4all.nl (Tijs Wickardt) Date: Tue, 11 Dec 2007 21:30:30 +0100 (CET) Subject: [Python.NET] Trouble getting Python for .NET to work in Ableton Live Message-ID: <13171.86.84.134.179.1197405030.squirrel@webmail.xs4all.nl> Hi group, I'm new here, so let me start with a small introduction: I'm a Progress developer (RDBMS with it's own 4GL) for a living, with some experience in C++ and C#, and I'm into music. Python is new to me, but doesn't seem so hard to learn (at least the basics). So sorry beforehand for some silly questions which I should have posted at a Python noob forum ;) Here's the question: The provided examples with Python for .NET run fine with the supplied python.exe on my Win32 XP SP2. I previously had problems with using the CLR.dll (Python .NET 1.0) inside a default Python 2.4.4 installation, and asked Brian Lloyd about this, but it was apparently an installation problem; now, on another machine, this imports fine (import CLR). It was a Python 2.5.1 installation on the other machine, maybe that's the difference. What I'd really like to do however, is the following: In a music program called Ableton Live, Python scripts are used to make interfaces between hardware midi controllers and Ableton Live. I'd like to use Python for .NET here, since I have several C# libraries I'd like to use for my mappings (and other stuff). When I copy "Python.Runtime.dll" and "CLR.dll" to a subfolder with a python script of Ableton Live, it compiles into .pyc. Ableton Live however gives a message "A serious error has occured", and on shutdown of the program, a memory fault causes the MS debugger to launch. Not good. Is what I want possible? Should I add more code to the .py scripts? The only thing I've added was "import CLR" in the first line of "__init__.py" (plus a newline character oc). Should I use a CLR.dll for Python 2.2, and does that exist? With the Python for .NET 2.0, I don't see a CLR.dll anymore. Only a "clr.so" of which I have no clue, and doesn't import. How should I use it? Here is some more info on Ableton Live's Python implementation (quoted from www.liveapi.org, which is down at the moment): # The current limitations that really stand out are: Ableton's Python environment is based on a stripped down Python 2.2 install # Updates are limited to 60ms (16 times a second) # Threads in Ableton's Python environment are only polled every 100ms, sys.setcheckinterval() doesn't seem to affect this. # No select.py seems to work, although we suspect that this could be easily resolved with some additional effort. There's an incompatibility between Ableton's Python and the 'standard' Python 2.2 major release. They appear to be different flavors. Any help appreciated, Kind regards, Tijs Wickardt From hsu.feihong at yahoo.com Wed Dec 12 00:18:03 2007 From: hsu.feihong at yahoo.com (Feihong Hsu) Date: Tue, 11 Dec 2007 15:18:03 -0800 (PST) Subject: [Python.NET] Trouble getting Python for .NET to work in Ableton Live In-Reply-To: <13171.86.84.134.179.1197405030.squirrel@webmail.xs4all.nl> Message-ID: <797855.96963.qm@web34807.mail.mud.yahoo.com> Python 2.2 is a seriously old version of Python. There's no download of Python.NET for Python 2.2 that I can see. You'd have to compile that yourself, and I don't even know what version of Visual C++ was used to compile Python 2.2 for Windows. Maybe the best solution at this point would be to use the popen2 module to spawn your Python.NET-using scripts as subprocesses, and communicate with your Ableton Live scripts using lines of strings. Cheers, Feihong Tijs Wickardt wrote: Hi group, I'm new here, so let me start with a small introduction: I'm a Progress developer (RDBMS with it's own 4GL) for a living, with some experience in C++ and C#, and I'm into music. Python is new to me, but doesn't seem so hard to learn (at least the basics). So sorry beforehand for some silly questions which I should have posted at a Python noob forum ;) Here's the question: The provided examples with Python for .NET run fine with the supplied python.exe on my Win32 XP SP2. I previously had problems with using the CLR.dll (Python .NET 1.0) inside a default Python 2.4.4 installation, and asked Brian Lloyd about this, but it was apparently an installation problem; now, on another machine, this imports fine (import CLR). It was a Python 2.5.1 installation on the other machine, maybe that's the difference. What I'd really like to do however, is the following: In a music program called Ableton Live, Python scripts are used to make interfaces between hardware midi controllers and Ableton Live. I'd like to use Python for .NET here, since I have several C# libraries I'd like to use for my mappings (and other stuff). When I copy "Python.Runtime.dll" and "CLR.dll" to a subfolder with a python script of Ableton Live, it compiles into .pyc. Ableton Live however gives a message "A serious error has occured", and on shutdown of the program, a memory fault causes the MS debugger to launch. Not good. Is what I want possible? Should I add more code to the .py scripts? The only thing I've added was "import CLR" in the first line of "__init__.py" (plus a newline character oc). Should I use a CLR.dll for Python 2.2, and does that exist? With the Python for .NET 2.0, I don't see a CLR.dll anymore. Only a "clr.so" of which I have no clue, and doesn't import. How should I use it? Here is some more info on Ableton Live's Python implementation (quoted from www.liveapi.org, which is down at the moment): # The current limitations that really stand out are: Ableton's Python environment is based on a stripped down Python 2.2 install # Updates are limited to 60ms (16 times a second) # Threads in Ableton's Python environment are only polled every 100ms, sys.setcheckinterval() doesn't seem to affect this. # No select.py seems to work, although we suspect that this could be easily resolved with some additional effort. There's an incompatibility between Ableton's Python and the 'standard' Python 2.2 major release. They appear to be different flavors. Any help appreciated, Kind regards, Tijs Wickardt _________________________________________________ Python.NET mailing list - PythonDotNet at python.org http://mail.python.org/mailman/listinfo/pythondotnet --------------------------------- Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20071211/5459d46a/attachment.htm From lists at cheimes.de Wed Dec 12 18:30:01 2007 From: lists at cheimes.de (Christian Heimes) Date: Wed, 12 Dec 2007 18:30:01 +0100 Subject: [Python.NET] Trouble getting Python for .NET to work in Ableton Live In-Reply-To: <797855.96963.qm@web34807.mail.mud.yahoo.com> References: <13171.86.84.134.179.1197405030.squirrel@webmail.xs4all.nl> <797855.96963.qm@web34807.mail.mud.yahoo.com> Message-ID: <47601A99.7080108@cheimes.de> Feihong Hsu wrote: > Python 2.2 is a seriously old version of Python. There's no download of Python.NET for Python 2.2 that I can see. You'd have to compile that yourself, and I don't even know what version of Visual C++ was used to compile Python 2.2 for Windows. Maybe the best solution at this point would be to use the popen2 module to spawn your Python.NET-using scripts as subprocesses, and communicate with your Ableton Live scripts using lines of strings. Python Dot NET doesn't support Python 2.2. It hardly supports 2.3 and 2.4. I keep 2.4 support around because Zope still uses 2.4. And I only added support to 2.3 because somebody asked me very nicely and the change to the code was was trivial. However 2.2 is a no go for me. The API and ABI changes between 2.2 and 2.3 an too great and 2.2 is *really* old. Christian From lance23runner at yahoo.com Sun Dec 9 22:01:31 2007 From: lance23runner at yahoo.com (lance23runner) Date: Sun, 9 Dec 2007 13:01:31 -0800 (PST) Subject: [Python.NET] Accessing class interface with private methods In-Reply-To: <93727.68378.qm@web34805.mail.mud.yahoo.com> References: <123772.15900.qm@web52608.mail.re2.yahoo.com> <93727.68378.qm@web34805.mail.mud.yahoo.com> Message-ID: <14243281.post@talk.nabble.com> I forgot to add "Implements Iface.Func" to method Func, I hope this doesn't confuse my problem. It is added below. The private method Func is accessible in VB.NET using the public IFACE. This is intended so the class does not see these methods, but it can access them using the IFACE property. A protected method doesn't provide the abstraction. Thanks, -Alex Feihong Hsu wrote: > > This is not supported. You can't access private methods in C# or VB.NET > either, so why should Python.NET be able to access them? But one thing to > note is that you CAN access protected methods directly in Pyhon.NET (you > don't have to make a subclass to use a protected method). > > - Feihong > > alex omoto wrote: Hi, > > I am having trouble using Python.NET in accessing class interface methods > that are declared private. As an example, > > Public Interface Iface > Property Func() As Boolean > End Interface > > Public Class Foo > Implements Iface > > Private Function Func() As Boolean Implements Iface.Func > Return True > End Function > > Public ReadOnly Property IFACE() As Iface > Get > Return Me > End Get > End Property > End Class > > Then using Python 2.5 with Python.Net 2.0 alpha 2, I cannot access the > method. Is this supported? > > import clr > import Foo > f = Foo() > f.IFACE # OK > f.IFACE.Func() # results in Attribute error > > > Thanks, > Alex > > > --------------------------------- > Never miss a thing. Make Yahoo your homepage. > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet > > > --------------------------------- > Looking for last minute shopping deals? Find them fast with Yahoo! > Search. > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet > -- View this message in context: http://www.nabble.com/Accessing-class-interface-with-private-methods-tp14234892p14243281.html Sent from the Python - pythondotnet mailing list archive at Nabble.com. From lists at cheimes.de Wed Dec 12 18:30:01 2007 From: lists at cheimes.de (Christian Heimes) Date: Wed, 12 Dec 2007 18:30:01 +0100 Subject: [Python.NET] Trouble getting Python for .NET to work in Ableton Live In-Reply-To: <797855.96963.qm@web34807.mail.mud.yahoo.com> References: <13171.86.84.134.179.1197405030.squirrel@webmail.xs4all.nl> <797855.96963.qm@web34807.mail.mud.yahoo.com> Message-ID: <47601A99.7080108@cheimes.de> Feihong Hsu wrote: > Python 2.2 is a seriously old version of Python. There's no download of Python.NET for Python 2.2 that I can see. You'd have to compile that yourself, and I don't even know what version of Visual C++ was used to compile Python 2.2 for Windows. Maybe the best solution at this point would be to use the popen2 module to spawn your Python.NET-using scripts as subprocesses, and communicate with your Ableton Live scripts using lines of strings. Python Dot NET doesn't support Python 2.2. It hardly supports 2.3 and 2.4. I keep 2.4 support around because Zope still uses 2.4. And I only added support to 2.3 because somebody asked me very nicely and the change to the code was was trivial. However 2.2 is a no go for me. The API and ABI changes between 2.2 and 2.3 an too great and 2.2 is *really* old. Christian From brian.lloyd at revolutionhealth.com Wed Dec 12 19:18:25 2007 From: brian.lloyd at revolutionhealth.com (Brian Lloyd) Date: Wed, 12 Dec 2007 13:18:25 -0500 Subject: [Python.NET] Trouble getting Python for .NET to work in Ableton Live In-Reply-To: <47601A99.7080108@cheimes.de> Message-ID: Not sure how insane this is, but if you want to really roll your sleeves up you might be able to checkout the old python2.2-supporting branch of python.net and build it using the .NET 2.x tool chain. If it works (no guarantees, but it might), then you should at least be able to load .net 2.x assemblies, though you wouldn't be able to leverage features that were supported in .net 1.0. I don't know much about Ableton (I'm a Sonar guy...), but if they haven't done anything too weird to the python they ship with you could also investigate dropping in a newer python exe, dlls and libs... -Brian On 12/12/07 12:30 PM, "Christian Heimes" wrote: > Feihong Hsu wrote: >> Python 2.2 is a seriously old version of Python. There's no download of >> Python.NET for Python 2.2 that I can see. You'd have to compile that >> yourself, and I don't even know what version of Visual C++ was used to >> compile Python 2.2 for Windows. Maybe the best solution at this point would >> be to use the popen2 module to spawn your Python.NET-using scripts as >> subprocesses, and communicate with your Ableton Live scripts using lines of >> strings. > > Python Dot NET doesn't support Python 2.2. It hardly supports 2.3 and > 2.4. I keep 2.4 support around because Zope still uses 2.4. And I only > added support to 2.3 because somebody asked me very nicely and the > change to the code was was trivial. > > However 2.2 is a no go for me. The API and ABI changes between 2.2 and > 2.3 an too great and 2.2 is *really* old. > > Christian > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet -------------------------- Brian Lloyd brian.lloyd at revolutionhealth.com From brian.lloyd at revolutionhealth.com Wed Dec 12 19:18:25 2007 From: brian.lloyd at revolutionhealth.com (Brian Lloyd) Date: Wed, 12 Dec 2007 13:18:25 -0500 Subject: [Python.NET] Trouble getting Python for .NET to work in Ableton Live In-Reply-To: <47601A99.7080108@cheimes.de> Message-ID: Not sure how insane this is, but if you want to really roll your sleeves up you might be able to checkout the old python2.2-supporting branch of python.net and build it using the .NET 2.x tool chain. If it works (no guarantees, but it might), then you should at least be able to load .net 2.x assemblies, though you wouldn't be able to leverage features that were supported in .net 1.0. I don't know much about Ableton (I'm a Sonar guy...), but if they haven't done anything too weird to the python they ship with you could also investigate dropping in a newer python exe, dlls and libs... -Brian On 12/12/07 12:30 PM, "Christian Heimes" wrote: > Feihong Hsu wrote: >> Python 2.2 is a seriously old version of Python. There's no download of >> Python.NET for Python 2.2 that I can see. You'd have to compile that >> yourself, and I don't even know what version of Visual C++ was used to >> compile Python 2.2 for Windows. Maybe the best solution at this point would >> be to use the popen2 module to spawn your Python.NET-using scripts as >> subprocesses, and communicate with your Ableton Live scripts using lines of >> strings. > > Python Dot NET doesn't support Python 2.2. It hardly supports 2.3 and > 2.4. I keep 2.4 support around because Zope still uses 2.4. And I only > added support to 2.3 because somebody asked me very nicely and the > change to the code was was trivial. > > However 2.2 is a no go for me. The API and ABI changes between 2.2 and > 2.3 an too great and 2.2 is *really* old. > > Christian > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet -------------------------- Brian Lloyd brian.lloyd at revolutionhealth.com From brian.lloyd at revolutionhealth.com Wed Dec 12 19:32:42 2007 From: brian.lloyd at revolutionhealth.com (Brian Lloyd) Date: Wed, 12 Dec 2007 13:32:42 -0500 Subject: [Python.NET] Accessing class interface with private methods In-Reply-To: <14243281.post@talk.nabble.com> Message-ID: have you tried explicitly calling this through the interface? You need to do something similar to a cast in C#: from mynamespace import Foo, Iface inst = Foo() # create an instance wrapped = Iface(inst) # 'cast' to the interface wrapped.Func() # should now work hope this helps, -Brian On 12/9/07 4:01 PM, "lance23runner" wrote: > > I forgot to add "Implements Iface.Func" to method Func, I hope this doesn't > confuse my problem. It is added below. > > The private method Func is accessible in VB.NET using the public IFACE. > This is intended so the class does not see these methods, but it can access > them using the IFACE property. A protected method doesn't provide the > abstraction. > > Thanks, > -Alex > > > > Feihong Hsu wrote: >> >> This is not supported. You can't access private methods in C# or VB.NET >> either, so why should Python.NET be able to access them? But one thing to >> note is that you CAN access protected methods directly in Pyhon.NET (you >> don't have to make a subclass to use a protected method). >> >> - Feihong >> >> alex omoto wrote: Hi, >> >> I am having trouble using Python.NET in accessing class interface methods >> that are declared private. As an example, >> >> Public Interface Iface >> Property Func() As Boolean >> End Interface >> >> Public Class Foo >> Implements Iface >> >> Private Function Func() As Boolean Implements Iface.Func >> Return True >> End Function >> >> Public ReadOnly Property IFACE() As Iface >> Get >> Return Me >> End Get >> End Property >> End Class >> >> Then using Python 2.5 with Python.Net 2.0 alpha 2, I cannot access the >> method. Is this supported? >> >> import clr >> import Foo >> f = Foo() >> f.IFACE # OK >> f.IFACE.Func() # results in Attribute error >> >> >> Thanks, >> Alex From wickardt at xs4all.nl Thu Dec 13 18:59:44 2007 From: wickardt at xs4all.nl (Tijs Wickardt) Date: Thu, 13 Dec 2007 18:59:44 +0100 (CET) Subject: [Python.NET] Trouble getting Python for .NET to work in Ableton Live Message-ID: <18123.82.95.10.159.1197568784.squirrel@webmail.xs4all.nl> Thanks for the reply Brian, and also Christian Heimes and Feihong Hsu. > Not sure how insane this is, but if you want to really roll your sleeves > up you might be able to checkout the old python2.2-supporting branch of > python.net and build it using the .NET 2.x tool chain. I'll look into that, thanks > > If it works (no guarantees, but it might), then you should at least be > able > to load .net 2.x assemblies, though you wouldn't be able to leverage > features that were supported in .net 1.0. > This shouldn't be too much of a restriction. If I build my assemblies with .net 2.0 it should ( /might) work? On problem though - how do i use the "pythonnet-2.0-alpha2" anyway in a separate python? Can't seem to find anything about it in the docs. I can build it using VS2005, but that gives me a python.exe and a "Python.Runtime.dll", which I suspect is where all the magic is. If I say "import Python.Runtime" from a normal python.exe, I get the message the following: >>> import Python.Runtime Traceback (most recent call last): File "", line 1, in ImportError: No module named Python.Runtime I guess what I'm doing doesn't make sense at all, Python.Runtime.dll is probably a .net assembly. But how then? > I don't know much about Ableton (I'm a Sonar guy...), but if they haven't > done anything too weird to the python they ship with you could also > investigate dropping in a newer python exe, dlls and libs... > Ableton comes as one big .exe (about 20MB). I'd have to hack it, and have no idea how to do that... > -Brian Thanks, Tijs P.S. Feihong: Using popen2 wouldn't be the best workaround for me I think. Liveapi has a telnet and OSC server that would probably serve me best. I'd prefer to use .net directly however, and save me the overhead of socket traffic. If it's not possible, it's not possible, and I'll use liveapi. Thanks again, Tijs From lists at cheimes.de Thu Dec 13 19:16:44 2007 From: lists at cheimes.de (Christian Heimes) Date: Thu, 13 Dec 2007 19:16:44 +0100 Subject: [Python.NET] Trouble getting Python for .NET to work in Ableton Live In-Reply-To: <18123.82.95.10.159.1197568784.squirrel@webmail.xs4all.nl> References: <18123.82.95.10.159.1197568784.squirrel@webmail.xs4all.nl> Message-ID: <4761770C.8080705@cheimes.de> Tijs Wickardt wrote: > On problem though - how do i use the "pythonnet-2.0-alpha2" anyway in a > separate python? Can't seem to find anything about it in the docs. I can > build it using VS2005, but that gives me a python.exe and a > "Python.Runtime.dll", which I suspect is where all the magic is. If I say > "import Python.Runtime" from a normal python.exe, I get the message the > following: The magic is in clr.pyd. You have to import the python dynamic extension (hence the name) in order to use the CLR features in a common Python. The clr.pyd in the alpha zip files doesn't work properly. You have to compile your own version with VS. > Ableton comes as one big .exe (about 20MB). I'd have to hack it, and have > no idea how to do that... I fear it's not going to work. A big exe sounds like a static inclusion of Python. PythonDotNET isn't compatible with static linking of the pythoncore library. It requires a pythonXX.dll to work. Christian From wickardt at xs4all.nl Thu Dec 13 21:03:11 2007 From: wickardt at xs4all.nl (Tijs Wickardt) Date: Thu, 13 Dec 2007 21:03:11 +0100 (CET) Subject: [Python.NET] Trouble getting Python for .NET to work in Ableton Live Message-ID: <8325.82.95.10.159.1197576191.squirrel@webmail.xs4all.nl> Hi Christian, > The magic is in clr.pyd. You have to import the python dynamic extension > (hence the name) in order to use the CLR features in a common Python. > The clr.pyd in the alpha zip files doesn't work properly. You have to > compile your own version with VS. Thanks, that helps. "import clr" is indeed working with a newly built clr.pyd in a standard Python 2.5.1. After that I can import .net libraries, thanks for your help. >> Ableton comes as one big .exe (about 20MB). I'd have to hack it, and.. > > I fear it's not going to work. A big exe sounds like a static inclusion > of Python. PythonDotNET isn't compatible with static linking of the > pythoncore library. It requires a pythonXX.dll to work. Too bad. Thank you for your clear answer. Thanks, Tijs From lists at cheimes.de Thu Dec 13 19:16:44 2007 From: lists at cheimes.de (Christian Heimes) Date: Thu, 13 Dec 2007 19:16:44 +0100 Subject: [Python.NET] Trouble getting Python for .NET to work in Ableton Live In-Reply-To: <18123.82.95.10.159.1197568784.squirrel@webmail.xs4all.nl> References: <18123.82.95.10.159.1197568784.squirrel@webmail.xs4all.nl> Message-ID: <4761770C.8080705@cheimes.de> Tijs Wickardt wrote: > On problem though - how do i use the "pythonnet-2.0-alpha2" anyway in a > separate python? Can't seem to find anything about it in the docs. I can > build it using VS2005, but that gives me a python.exe and a > "Python.Runtime.dll", which I suspect is where all the magic is. If I say > "import Python.Runtime" from a normal python.exe, I get the message the > following: The magic is in clr.pyd. You have to import the python dynamic extension (hence the name) in order to use the CLR features in a common Python. The clr.pyd in the alpha zip files doesn't work properly. You have to compile your own version with VS. > Ableton comes as one big .exe (about 20MB). I'd have to hack it, and have > no idea how to do that... I fear it's not going to work. A big exe sounds like a static inclusion of Python. PythonDotNET isn't compatible with static linking of the pythoncore library. It requires a pythonXX.dll to work. Christian From lance23runner at yahoo.com Sat Dec 15 01:58:01 2007 From: lance23runner at yahoo.com (lance23runner) Date: Fri, 14 Dec 2007 16:58:01 -0800 (PST) Subject: [Python.NET] Accessing class interface with private methods In-Reply-To: References: <123772.15900.qm@web52608.mail.re2.yahoo.com> <93727.68378.qm@web34805.mail.mud.yahoo.com> <14243281.post@talk.nabble.com> Message-ID: <14339876.post@talk.nabble.com> Cool. Thanks Brian, this worked! -Alex Brian Lloyd-5 wrote: > > have you tried explicitly calling this through the interface? You > need to do something similar to a cast in C#: > > from mynamespace import Foo, Iface > > inst = Foo() # create an instance > > wrapped = Iface(inst) # 'cast' to the interface > > wrapped.Func() # should now work > > hope this helps, > > -Brian > > > > On 12/9/07 4:01 PM, "lance23runner" wrote: > >> >> I forgot to add "Implements Iface.Func" to method Func, I hope this >> doesn't >> confuse my problem. It is added below. >> >> The private method Func is accessible in VB.NET using the public IFACE. >> This is intended so the class does not see these methods, but it can >> access >> them using the IFACE property. A protected method doesn't provide the >> abstraction. >> >> Thanks, >> -Alex >> >> >> >> Feihong Hsu wrote: >>> >>> This is not supported. You can't access private methods in C# or VB.NET >>> either, so why should Python.NET be able to access them? But one thing >>> to >>> note is that you CAN access protected methods directly in Pyhon.NET (you >>> don't have to make a subclass to use a protected method). >>> >>> - Feihong >>> >>> alex omoto wrote: Hi, >>> >>> I am having trouble using Python.NET in accessing class interface >>> methods >>> that are declared private. As an example, >>> >>> Public Interface Iface >>> Property Func() As Boolean >>> End Interface >>> >>> Public Class Foo >>> Implements Iface >>> >>> Private Function Func() As Boolean Implements Iface.Func >>> Return True >>> End Function >>> >>> Public ReadOnly Property IFACE() As Iface >>> Get >>> Return Me >>> End Get >>> End Property >>> End Class >>> >>> Then using Python 2.5 with Python.Net 2.0 alpha 2, I cannot access the >>> method. Is this supported? >>> >>> import clr >>> import Foo >>> f = Foo() >>> f.IFACE # OK >>> f.IFACE.Func() # results in Attribute error >>> >>> >>> Thanks, >>> Alex > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet > > -- View this message in context: http://www.nabble.com/Accessing-class-interface-with-private-methods-tp14234892p14339876.html Sent from the Python - pythondotnet mailing list archive at Nabble.com. From kyle.stevens at thenortheastgroup.com Tue Dec 18 21:02:29 2007 From: kyle.stevens at thenortheastgroup.com (Kyle Stevens) Date: Tue, 18 Dec 2007 15:02:29 -0500 Subject: [Python.NET] Accessing Public Functions in Module Message-ID: <47682755.60506@thenortheastgroup.com> We have an application that was developed in Visual Basic, and would like to use Python for .NET to extend it. I've played around with it a bit, and everything works fine if it is within a class in the .Net assembly. However, there are a number of components that exist as public functions within a module. I cannot seem to access them from Python for .NET. My latest session is shown below, where I try to import and use the function, "NonQuery" within the module, "SQL_Module" to no avail. Thanks for any help, and thanks for this wonderful piece of software. I can't wait to start programming some things with this instead of Visual Basic. Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. Z:\>\\buffalo02\share\IT\python\python\python.exe Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import Nepco4 Traceback (most recent call last): File "", line 1, in ImportError: No module named Nepco4 >>> from NepcoV2 import Order >>> from NepcoV2 import NonQuery Traceback (most recent call last): File "", line 1, in ImportError: cannot import name NonQuery >>> from NepcoV2 import SQL_Module.NonQuery File "", line 1 from NepcoV2 import SQL_Module.NonQuery ^ SyntaxError: invalid syntax >>> from NepcoV2.SQL_Module import NonQuery Traceback (most recent call last): File "", line 1, in ImportError: No module named SQL_Module >>> import Nepco4.NepcoV2 Traceback (most recent call last): File "", line 1, in ImportError: No module named Nepco4.NepcoV2 >>> from Nepco4 import NepcoV2 Traceback (most recent call last): File "", line 1, in ImportError: No module named Nepco4 >>> from NepcoV2 import SQL_Module Traceback (most recent call last): File "", line 1, in ImportError: cannot import name SQL_Module >>> from NepcoV2 import SQL_Module5 Traceback (most recent call last): File "", line 1, in ImportError: cannot import name SQL_Module5 >>> from NepcoV2 import SQL_Modulf Traceback (most recent call last): File "", line 1, in ImportError: cannot import name SQL_Modulf >>> from NepcoV2 import Shipping_Detail_Report >>> from NepcoV2 import * >>> NonQuery() Traceback (most recent call last): File "", line 1, in NameError: name 'NonQuery' is not defined >>> NepcoV2.NonQuery() Traceback (most recent call last): File "", line 1, in NameError: name 'NepcoV2' is not defined >>> From hsu.feihong at yahoo.com Tue Dec 18 21:47:34 2007 From: hsu.feihong at yahoo.com (Feihong Hsu) Date: Tue, 18 Dec 2007 12:47:34 -0800 (PST) Subject: [Python.NET] Accessing Public Functions in Module In-Reply-To: <47682755.60506@thenortheastgroup.com> Message-ID: <387581.87721.qm@web34808.mail.mud.yahoo.com> Can you access these same functions in C#? Maybe what you have to do is write a wrapper library for your VB.NET library in C#, and have Python access the library through the the wrapper. - Feihong Kyle Stevens wrote: We have an application that was developed in Visual Basic, and would like to use Python for .NET to extend it. I've played around with it a bit, and everything works fine if it is within a class in the .Net assembly. However, there are a number of components that exist as public functions within a module. I cannot seem to access them from Python for .NET. My latest session is shown below, where I try to import and use the function, "NonQuery" within the module, "SQL_Module" to no avail. Thanks for any help, and thanks for this wonderful piece of software. I can't wait to start programming some things with this instead of Visual Basic. Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. Z:\>\\buffalo02\share\IT\python\python\python.exe Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import Nepco4 Traceback (most recent call last): File "", line 1, in ImportError: No module named Nepco4 >>> from NepcoV2 import Order >>> from NepcoV2 import NonQuery Traceback (most recent call last): File "", line 1, in ImportError: cannot import name NonQuery >>> from NepcoV2 import SQL_Module.NonQuery File "", line 1 from NepcoV2 import SQL_Module.NonQuery ^ SyntaxError: invalid syntax >>> from NepcoV2.SQL_Module import NonQuery Traceback (most recent call last): File "", line 1, in ImportError: No module named SQL_Module >>> import Nepco4.NepcoV2 Traceback (most recent call last): File "", line 1, in ImportError: No module named Nepco4.NepcoV2 >>> from Nepco4 import NepcoV2 Traceback (most recent call last): File "", line 1, in ImportError: No module named Nepco4 >>> from NepcoV2 import SQL_Module Traceback (most recent call last): File "", line 1, in ImportError: cannot import name SQL_Module >>> from NepcoV2 import SQL_Module5 Traceback (most recent call last): File "", line 1, in ImportError: cannot import name SQL_Module5 >>> from NepcoV2 import SQL_Modulf Traceback (most recent call last): File "", line 1, in ImportError: cannot import name SQL_Modulf >>> from NepcoV2 import Shipping_Detail_Report >>> from NepcoV2 import * >>> NonQuery() Traceback (most recent call last): File "", line 1, in NameError: name 'NonQuery' is not defined >>> NepcoV2.NonQuery() Traceback (most recent call last): File "", line 1, in NameError: name 'NepcoV2' is not defined >>> _________________________________________________ Python.NET mailing list - PythonDotNet at python.org http://mail.python.org/mailman/listinfo/pythondotnet --------------------------------- Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20071218/23bf815d/attachment.htm From brian.lloyd at revolutionhealth.com Tue Dec 18 21:57:18 2007 From: brian.lloyd at revolutionhealth.com (Brian Lloyd) Date: Tue, 18 Dec 2007 15:57:18 -0500 Subject: [Python.NET] Accessing Public Functions in Module In-Reply-To: <387581.87721.qm@web34808.mail.mud.yahoo.com> Message-ID: Most likely the vb.net compiler does some shenanigans and places this (in the IL) in a place that might not be obvious (like a generated class). If you use reflector on the assembly you can probably discover what its real name is and try to import that from python. -Brian On 12/18/07 3:47 PM, "Feihong Hsu" wrote: > Can you access these same functions in C#? Maybe what you have to do is write > a wrapper library for your VB.NET library in C#, and have Python access the > library through the the wrapper. > > - Feihong > > > Kyle Stevens wrote: >> We have an application that was developed in Visual Basic, and would >> like to use Python for .NET to extend it. I've played around with it a >> bit, and everything works fine if it is within a class in the .Net assembly. >> >> However, there are a number of components that exist as public functions >> within a module. I cannot seem to access them from Python for .NET. >> >> My latest session is shown below, where I try to import and use the >> function, "NonQuery" within the module, "SQL_Module" to no avail. >> >> Thanks for any help, and thanks for this wonderful piece of software. I >> can't wait to start programming some things with this instead of Visual >> Basic. >> >> Microsoft Windows XP [Version 5.1.2600] >> (C) Copyright 1985-2001 Microsoft Corp. >> >> Z:\>\\buffalo02\share\IT\python\python\python.exe >> Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit >> (Intel)] on >> win32 >> Type "help", "copyright", "credits" or "license" for more information. >>>>> >>> import Nepco4 >> Traceback (most recent call last): >> File "", line 1, in >> ImportError: No module named Nepco4 >>>>> >>> from NepcoV2 import Order >>>>> >>> from NepcoV2 import NonQuery >> Traceback (most recent call last): >> File "", line 1, in >> ImportError: cannot import name NonQuery >>>>> >>> from NepcoV2 import SQL_Module.NonQuery >> File "", line 1 >> from NepcoV2 import SQL_Module.NonQuery >> ^ >> SyntaxError: invalid syntax >>>>> >>> from NepcoV2.SQL_Module import NonQuery >> Traceback (most recent call last): >> File "", line 1, in >> ImportError: No module named SQL_Module >>>>> >>> import Nepco4.NepcoV2 >> Traceback (most recent call last): >> File "", line 1, in >> ImportError: No module named Nepco4.NepcoV2 >>>>> >>> from Nepco4 import NepcoV2 >> Traceback (most recent call last): >> File "", line 1, in >> ImportError: No module named Nepco4 >>>>> >>> from NepcoV2 import SQL_Module >> Traceback (most recent call last): >> File "", line 1, in >> ImportError: cannot import name SQL_Module >>>>> >>> from NepcoV2 import SQL_Module5 >> Traceback (most recent call last): >> File "", line 1, in >> ImportError: cannot import name SQL_Module5 >>>>> >>> from NepcoV2 import SQL_Modulf >> Traceback (most recent call last): >> File "", line 1, in >> ImportError: cannot import name SQL_Modulf >>>>> >>> from NepcoV2 import Shipping_Detail_Report >>>>> >>> from NepcoV2 import * >>>>> >>> NonQuery() >> Traceback (most recent call last): >> File "", line 1, in >> NameError: name 'NonQuery' is not defined >>>>> >>> NepcoV2.NonQuery() >> Traceback (most recent call last): >> File "", line 1, in >> NameError: name 'NepcoV2' is not defined >>>>> >>> >> _________________________________________________ >> Python.NET mailing list - PythonDotNet at python.org >> http://mail.python.org/mailman/listinfo/pythondotnet > > > > > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it > now. > tDypao8Wcj9tAcJ > > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet -------------------------- Brian Lloyd brian.lloyd at revolutionhealth.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20071218/8c554b10/attachment.htm From kyle.stevens at thenortheastgroup.com Tue Dec 18 22:40:18 2007 From: kyle.stevens at thenortheastgroup.com (Kyle Stevens) Date: Tue, 18 Dec 2007 16:40:18 -0500 Subject: [Python.NET] Accessing Public Functions in Module In-Reply-To: References: Message-ID: <47683E42.8060809@thenortheastgroup.com> Thanks. I downloaded a reflector from: http://www.aisto.com/roeder/dotnet/ By using that I could see that the module in question was declared friend (default, if not specified.. I guess), not public. I made it public and can now access the functions within it. So the compiler didn't mangle anything, it was just me not knowing what I was doing :). But your idea worked anyway. Thanks again. Brian Lloyd wrote: > Most likely the vb.net compiler does some shenanigans and places this > (in the IL) in a place that might not be obvious (like a generated class). > > If you use reflector on the assembly you can probably discover what its > real name is and try to import that from python. > > -Brian > > > On 12/18/07 3:47 PM, "Feihong Hsu" wrote: > > Can you access these same functions in C#? Maybe what you have to > do is write a wrapper library for your VB.NET library in C#, and > have Python access the library through the the wrapper. > > - Feihong > > > */Kyle Stevens /* wrote: > > We have an application that was developed in Visual Basic, and > would > like to use Python for .NET to extend it. I've played around > with it a > bit, and everything works fine if it is within a class in the > .Net assembly. > > However, there are a number of components that exist as public > functions > within a module. I cannot seem to access them from Python for > .NET. > > My latest session is shown below, where I try to import and > use the > function, "NonQuery" within the module, "SQL_Module" to no avail. > > Thanks for any help, and thanks for this wonderful piece of > software. I > can't wait to start programming some things with this instead > of Visual > Basic. > > Microsoft Windows XP [Version 5.1.2600] > (C) Copyright 1985-2001 Microsoft Corp. > > Z:\>\\buffalo02\share\IT\python\python\python.exe > Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 > 32 bit > (Intel)] on > win32 > Type "help", "copyright", "credits" or "license" for more > information. > >>> import Nepco4 > Traceback (most recent call last): > File "", line 1, in > ImportError: No module named Nepco4 > >>> from NepcoV2 import Order > >>> from NepcoV2 import NonQuery > Traceback (most recent call last): > File "", line 1, in > ImportError: cannot import name NonQuery > >>> from NepcoV2 import SQL_Module.NonQuery > File "", line 1 > from NepcoV2 import SQL_Module.NonQuery > ^ > SyntaxError: invalid syntax > >>> from NepcoV2.SQL_Module import NonQuery > Traceback (most recent call last): > File "", line 1, in > ImportError: No module named SQL_Module > >>> import Nepco4.NepcoV2 > Traceback (most recent call last): > File "", line 1, in > ImportError: No module named Nepco4.NepcoV2 > >>> from Nepco4 import NepcoV2 > Traceback (most recent call last): > File "", line 1, in > ImportError: No module named Nepco4 > >>> from NepcoV2 import SQL_Module > Traceback (most recent call last): > File "", line 1, in > ImportError: cannot import name SQL_Module > >>> from NepcoV2 import SQL_Module5 > Traceback (most recent call last): > File "", line 1, in > ImportError: cannot import name SQL_Module5 > >>> from NepcoV2 import SQL_Modulf > Traceback (most recent call last): > File "", line 1, in > ImportError: cannot import name SQL_Modulf > >>> from NepcoV2 import Shipping_Detail_Report > >>> from NepcoV2 import * > >>> NonQuery() > Traceback (most recent call last): > File "", line 1, in > NameError: name 'NonQuery' is not defined > >>> NepcoV2.NonQuery() > Traceback (most recent call last): > File "", line 1, in > NameError: name 'NepcoV2' is not defined > >>> > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet > > > > > ------------------------------------------------------------------------ > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. > Try it now. > > > > > ------------------------------------------------------------------------ > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet > > > > -------------------------- > Brian Lloyd > > brian.lloyd at revolutionhealth.com