[IronPython] Odd behaviour from nested classes

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


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

namespace Test {
     public class Aye {
         public class AyeBee {

import clr

 >>> 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.


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 Ironpython-users mailing list