From alberto at metapensiero.it Wed Aug 1 03:22:46 2007 From: alberto at metapensiero.it (Alberto Berti) Date: Wed, 01 Aug 2007 03:22:46 +0200 Subject: [Python.NET] Packages are wrongly initialized? Message-ID: <87y7gwjbfd.fsf@lizard.lizardnet> Hi all, i'm in the process of embedding python in a C# application. After initializing the engine, my application imports via (ImportModule) a custom package which contains the python side of my code. doing the following code raises an AttributeError Exception: PyObject pypackage = PythonEngine.ImportModule('pypackage'); PyObject sub_module = pypackage.GetAttr('sub_module'); <-- raises the exception here One other thing that isn't working is a non empty __init__.py inside the package; trying to import any symbol defined in the __init__.py also raises an AttributeError. instead, this line works as expected: PyObject pypackage = PythonEngine.ImportModule('pypackage.submodule'); I've tried the code with the old trunk and with the newer Christian's one. am I doing something wrong? Anyone as any clue? thanks in advance Alberto From alberto at metapensiero.it Wed Aug 1 05:46:34 2007 From: alberto at metapensiero.it (Alberto Berti) Date: Wed, 01 Aug 2007 05:46:34 +0200 Subject: [Python.NET] Packages are wrongly initialized? In-Reply-To: (Brian Lloyd's message of "Tue\, 31 Jul 2007 21\:55\:23 -0400") References: Message-ID: <87tzrjkjc5.fsf@lizard.lizardnet> >>>>> "Brian" == Brian Lloyd writes: Brian> Note that imports are subtley different than getattr Brian> behavior... does your main main 'pypackage' package Brian> contain something like the following in its __init__? Brian> from subpackage import * It's really late here, but if i correctly remember i've tried a star import, a named import and an empty __init__.py, all with the same effect, but i will retry asap, thanks. Alberto From lists at cheimes.de Wed Aug 1 08:06:12 2007 From: lists at cheimes.de (Christian Heimes) Date: Wed, 01 Aug 2007 08:06:12 +0200 Subject: [Python.NET] Packages are wrongly initialized? In-Reply-To: <87y7gwjbfd.fsf@lizard.lizardnet> References: <87y7gwjbfd.fsf@lizard.lizardnet> Message-ID: Alberto Berti wrote: > doing the following code raises an AttributeError Exception: > > PyObject pypackage = PythonEngine.ImportModule('pypackage'); > PyObject sub_module = pypackage.GetAttr('sub_module'); <-- raises the exception here That doesn't work under Python unless pypackage import submodule in its __init__.py: $ python Python 2.5.1 (r251:54863, May 2 2007, 16:56:35) [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import email >>> getattr(email, 'charset') Traceback (most recent call last): File "", line 1, in AttributeError: 'module' object has no attribute 'charset' >>> import email.charset >>> getattr(email, 'charset') Christian From brian.lloyd at revolutionhealth.com Wed Aug 1 03:55:23 2007 From: brian.lloyd at revolutionhealth.com (Brian Lloyd) Date: Tue, 31 Jul 2007 21:55:23 -0400 Subject: [Python.NET] Packages are wrongly initialized? In-Reply-To: <87y7gwjbfd.fsf@lizard.lizardnet> Message-ID: Note that imports are subtley different than getattr behavior... does your main main 'pypackage' package contain something like the following in its __init__? from subpackage import * -Brian On 7/31/07 9:22 PM, "Alberto Berti" wrote: > Hi all, > > i'm in the process of embedding python in a C# application. After > initializing the engine, my application imports via (ImportModule) a > custom package which contains the python side of my code. > > doing the following code raises an AttributeError Exception: > > PyObject pypackage = PythonEngine.ImportModule('pypackage'); > PyObject sub_module = pypackage.GetAttr('sub_module'); <-- raises the > exception here > > One other thing that isn't working is a non empty __init__.py inside > the package; trying to import any symbol defined in the __init__.py > also raises an AttributeError. > > instead, this line works as expected: > > PyObject pypackage = PythonEngine.ImportModule('pypackage.submodule'); > > I've tried the code with the old trunk and with the newer Christian's > one. > > am I doing something wrong? > Anyone as any clue? > > thanks in advance > > Alberto > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet -------------------------- Brian Lloyd brian.lloyd at revolutionhealth.com From lists at cheimes.de Fri Aug 3 14:21:06 2007 From: lists at cheimes.de (Christian Heimes) Date: Fri, 03 Aug 2007 14:21:06 +0200 Subject: [Python.NET] PythonNet news In-Reply-To: <8674D71026D5C848831DB7CA34B1C75862FD20@fds1wmail01.funddevelopmentservices.com> References: <8674D71026D5C848831DB7CA34B1C75862FD20@fds1wmail01.funddevelopmentservices.com> Message-ID: Maksim Kozyarchuk wrote: > Do you have a sense of what it would take to make current trunk > of PythonNet compatible with Python 2.3? I added some code for Python 2.3. Please consider it mostly working but not officially supported by me. The clr.so and the examples in src/monoclr/ don't build due missing set and subprocess modules and I run into some strange problems with large doubles. Christian From par at sundback.com Sat Aug 25 20:35:38 2007 From: par at sundback.com (=?iso-8859-1?Q?P=E4r_Sundb=E4ck?=) Date: Sat, 25 Aug 2007 20:35:38 +0200 Subject: [Python.NET] How to use Dll-methods with [out]-arguments and no constructor for the argument-class Message-ID: <000d01c7e746$bc56a370$0201a8c0@PskAmilo> Hi I am using Python .Net together with PythonWin 2.5. My task is to use a .Net assembly dll from a python testscript. The dll is written i C# to create interfaces by refering them as [out]arguments. I am supposed to be sending a reference to a datatype/interface and then get a handle to that created interface for further processing. The original C# method in the dll looks something like: HResult=CreateInstance([out] ICHardware hw) In python I receive this (ofcourse) when using the class (not instance) of the datatype as argument: >>> hw=ICHardware >>> ICProductFactory.CreateInstance(hw) Traceback (most recent call last): File "", line 1, in TypeError: No method matches given arguments My problem is that I can not create an instance of ICHardware from Python since the constructor is hidden in the dll (or not in there at all). In C# I would do like this when using the dll: ICHardware hw; ICProductFactory.CreateInstance(hw); hw.Method.... In Python this is not possible since I can not declare a variable without assign a value or running the constructor, or? Maybe someone knows a work-around for this. I'll be happy for all feedback. Regards /P?r -- Jag anv?nder gratisversionen av SPAMfighter f?r privata anv?ndare. 4941 spam har blivit blockerade hittills. Betalande anv?ndare har inte detta meddelande i sin e-post. H?mta gratis SPAMfighter h?r: http://www.spamfighter.com/lsv -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20070825/e448b50c/attachment.htm