[IronPython] Printing an object out as a string
curt at hagenlocher.org
Wed Jan 28 05:13:06 CET 2009
If you're willing to live on the bleeding edge and build from the latest
sources, it turns out that Tomas just added this functionality to the
hosting interfaces yesterday. ObjectOperations.Format(obj) should return a
string that matches what the REPL would have printed.
On Tue, Jan 27, 2009 at 7:52 PM, Jeff Slutter <jslutter at reactorzero.com>wrote:
> Given an object, how can I go about printing out that object as a string
> representing the object in Python syntax?
> I need something a little more powerful than just object.ToString()
> I need something like how the interactive console reports the result of
> the statement.
> For instance:
> a = [0,1,2]
> b = [a,8,9]
> If I pass 'b' to a function in C#, like:
> void SomeFunction( object obj )
> string objStr = ConvertToString( obj );
> Console.Write( objStr );
> it would print out:
> Obviously ToString() will work for simple things, but once I try to use
> lists or dictionaries it no longer works.
> Thank you,
> Users mailing list
> Users at lists.ironpython.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ironpython-users