views:

57

answers:

2

I want to do a deepcopy in IronPython, but when I write

import copy 

I get "no module named copy". How do I deepcopy in IronPython?

+5  A: 

Use IronPython version 2.6.1, and select the standard library option in the installer. An example from my installation:

IronPython 2.6.1 (2.6.10920.0) on .NET 2.0.50727.4927
Type "help", "copyright", "credits" or "license" for more information.
>>> import copy
>>> help(copy.deepcopy)
Help on function deepcopy in module copy:

deepcopy(x, memo=None, _nil=[])
    Deep copy operation on arbitrary Python objects.

    See the module's __doc__ string for more info.

>>> copy.deepcopy(range(5))
[0, 1, 2, 3, 4]
>>>
gimel
A: 

It's work only in IronPython console, in visual studio:

IronPython.Runtime.Exceptions.PythonImportErrorException was unhandled by user code
  Message="No module named copy"
  Source="IronPython"
  StackTrace:
       at IronPython.Modules.Builtin.__import__(ICallerContext context, String name, Object globals, Object locals, Object fromList)
       at __import__##4(ICallerContext , Object , Object , Object , Object )
       at IronPython.Runtime.Calls.FastCallableWithContextAny.Call(ICallerContext context, Object arg0, Object arg1, Object arg2, Object arg3)
       at IronPython.Runtime.Calls.BuiltinFunction.Call(ICallerContext context, Object arg0, Object arg1, Object arg2, Object arg3)
       at IronPython.Runtime.Operations.Ops.CallWithContext(ICallerContext context, Object func, Object arg0, Object arg1, Object arg2, Object arg3)
       at IronPython.Runtime.Importer.Import(PythonModule mod, String fullName, List from)
       at IronPython.Runtime.Operations.Ops.Import(PythonModule mod, String fullName)
       at Program.Initialize() in Program.py:line 4
       at IronPython.Runtime.Operations.Ops.ExecuteCompiled(InitializeModule init)
  InnerException: 
antazy