[Python.NET] import String : Uses PythonNet with current Pythoninstallation

Bruce Dodson bruce_dodson at hotmail.com
Wed Sep 29 01:42:17 CEST 2004


It's a bootstrapping problem.  The CLR module not only 
defines the namespace for .NET packages, but also registers 
the import hook for those packages.  So, without the "import 
CLR", the subpackage name cannot be found at the time when 
the first name lookup occurs.

The import hook can, and probably should be written in 
Python, to avoid the bootstrapping problem.  It would 
delegate to C# for CLR package references.

Bruce


-----
"f.kintzel" 
<f.kintzel at internet-access.de> 
wrote in message news:4157CD2F.5010501 at internet-access.de...
Hello,

I'm not shure why, but importing CLR-modules requires that 
the top-module is imported first, then submodules of it.
Try the following :

import CLR
import CLR.System
from CLR.System import String as CLRString

foo = CLRString('bar')
print foo






More information about the PythonDotNet mailing list