[IronPython] Odd behaviour from nested classes

Jonathan Jacobs korpse-ironpython at kaydash.za.net
Mon Jul 3 14:53:44 PDT 2006


Hi,

I just found some incredibly strange behaviour when using nested C# classes. 
Here's the repro:

Test.cs:
namespace Test {
     public class Aye {
         public class AyeBee {
         }
     }
}

hax/__init__.py:
import clr
clr.AddReferenceToFile('Test.dll')

 >>> import hax
 >>> import Test
 >>> Test.Aye
<type 'Aye'>
 >>> Test.Aye.AyeBee
Traceback (most recent call last):
   File , line 0, in <stdin>##15
AttributeError: type object 'Aye' has no attribute 'AyeBee'
 >>> import clr
 >>> Test.Aye.AyeBee
<type 'AyeBee'>

The trick here is hax/__init__.py, if I reference the assembly "manually" then 
the problem ceases to exist. I'm not sure whether this is a quirk of nested 
classes or the clr module itself.

Regards
-- 
Jonathan

When you meet a master swordsman,
show him your sword.
When you meet a man who is not a poet,
do not show him your poem.
                 -- Rinzai, ninth century Zen master


More information about the users mailing list