tags:

views:

33

answers:

1

I'm obviously missing something trivial, but I can't seem to import from System.Dynamic; to wit:

import clr
clr.AddReference('System.Dynamic')

which clearly adds the salient reference:

clr.References[2]
(< System.Dynamic, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a>)

but importing fails

import System.Dynamic

results in:

Traceback (most recent call last):
File "", line 1, in
ImportError: No module named Dynamic

What basic thing am I missing?

+1  A: 

The System.Dynamic assembly in .NET 4.0 actually includes no public surface area. It just has a bunch of internal types which are visible to the C# runtime assembly that are used for COM interop. The decision to make this all internal was made late enough in the product cycle that the assembly still remains.

Likely you want Microsoft.Dynamic instead which contains a superset of the functionality in System.Dynamic. Microsoft.Dynamic is shipped w/ IronPython.

Dino Viehland
Exact same behavior with Microsoft.Dynamic.
michael
Well after doing an add ref to Microsoft.Dynamic you won't be able to import a "System.Dynamic" namespace. Instead you'll need to import namespaces defined in that assembly such as Microsoft.Scripting.
Dino Viehland
One useful way to see what namespaces are available is to do: x = clr.LoadAssemblyByName('Microsoft.Dynamic')dir(x) which will let you inspect the namespaces in an assembly (sorry for the formatting, enter is commiting edits for some reason instead of inserting new lines)
Dino Viehland