On Mon, 17 Oct 2005 17:25:35 +0800, James Gan wrote:

> I want the object printed in a readable format. For example,
> x =[a, b, c, [d e]] will be printed as:
> x--a
>   |_b
>   |_c
>   |___d
>     |_e

I think you missed an "un-" in your first sentence.

:-)

In general, if you want special/fancy/bizarre printing, you should either
write your own custom functions, or sub-class the objects in question.

E.g. 

def multiline_print(L, indent=""):
    """Multi-line printing of lists.
    WARNING: Untested and probably full of bugs.
    """
    for item in L:
        if type(item) == list:
            multiline_print(item, indent + "    ")
        else:
            print indent + "|_" + str(item)


Hope this helps.



-- 
Steven.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to