[IronPython] clr.ImportExtensions are not available outside module ?

daniel kottow dkottowk at yahoo.com
Thu May 12 18:57:51 CEST 2011


Just as Dave Wald, I have also trying out the ImportExtensions methods which I 
personally find very useful, thank you for implementing. Everything is working 
fine on using 2.7 (and .net 4), but extension methods loaded by one module seem 
not available on another... 

I will stick to Dave's code exmaple:

import clr
import System
from System import Linq


class Product(object):
     def __init__(self, cat, id, qtyOnHand ):
         self.Cat = cat
         self.ID = id
         self.QtyOnHand = qtyOnHand
         self.Q = self.QtyOnHand 

If I put this into a file, lets say test.py and now use the module on the 
command line:

>>> import test
>>> products = [test.Product('food', i, 10) for i in range(3)]
>>> products.Where
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'list' object has no attribute 'Where'

The linq extensions are not available. I have to re-import them:

>>> test.clr.ImportExtensions(test.Linq)
>>> products.Where
<built-in method Where of list object at 0x000000000000002B>

Is this a current limitation, or should I be doing things differently ?
Any help appreciated.


More information about the Ironpython-users mailing list