[IronPython] Compiling into a DLL with pyc.py and then calling the class

Michael Foord fuzzyman at voidspace.org.uk
Tue Aug 26 20:16:40 CEST 2008


hellosticky wrote:
> Hi, I'm new to IronPython. I have the following test.py:
>
> from System import *
> from System.Collections.Generic import *
> from System.Text import *
> from PublicDomain import *
>
> class test:
> 	def foo(self):
> 		return GlobalConstants.EarthEquatorialRadiusInKilometers
>
> PublicDomain is a package from here: http://www.codeplex.com/PublicDomain
>
> I compile this python file into a DLL with:
>
> ipy.exe pyc.py /out:test /target:dll /r:..\publicdomain\PublicDomain.dll test.py
>
> Everything looks good in ildasm. Then I load up ipy.exe:
>
>   
>> ipy
>>     
> IronPython 2.0 Beta (2.0.0.4000) on .NET 2.0.50727.1433
> Type "help", "copyright", "credits" or "license" for more information.
>   
>>>> import clr
>>>> clr.AddReference("test")
>>>> t = test()
>>>>         
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> NameError: name 'test' is not defined
>
> Any ideas what I'm doing wrong?
>   

Having added the reference you will need to import test.

I assume that 'from test import test' is the required magic.

Michael

> Thanks!
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>   


-- 
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/
http://www.trypython.org/
http://www.ironpython.info/
http://www.theotherdelia.co.uk/
http://www.resolverhacks.net/




More information about the Ironpython-users mailing list