Beispiel #1
0
        /// <summary>
        /// Object.ToString() displays the CLI type name.  But we want to display the class name (e.g.
        /// '<foo object at 0x000000000000002C>' unless we've overridden __repr__ but not __str__ in
        /// which case we'll display the result of __repr__.
        /// </summary>
        public static string ToStringHelper(ISuperDynamicObject o)
        {
            object   ret;
            UserType ut = o.GetDynamicType() as UserType;

            if (ut.TryLookupSlot(DefaultContext.Default, SymbolTable.Repr, out ret))
            {
                return(Converter.ConvertToString(Ops.Call(Ops.GetDescriptor(ret, o, ut))));
            }

            return(PythonType.ReprMethod(o).ToString());
        }