[IronPython] How can you create set/frozenset from C# ?

Michael Foord fuzzyman at voidspace.org.uk
Thu Oct 30 23:55:41 CET 2008


Dan Eloff wrote:
> It seems to me that you have to use __init__/__new__ supplying
> CodeContext as necessary. Unlike list and tuple which have public
> constructors and PythonOps helpers, there doesn't seem to be any
> public api for creating sets. Am I right?
>
> Thanks,
> -Dan
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>   

SetCollection has a public constructor.

If you need the CodeContext for __new__ then you can get one like this:

LanguageContext language = HostingHelpers.GetLanguageContext(engine);
CodeContext co = new CodeContext(new Scope(), language)

Michael

-- 
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog





More information about the Ironpython-users mailing list