[Tutor] Hello, and a newbie question

Alan Gauld alan.gauld at btinternet.com
Wed Apr 17 01:39:14 CEST 2013


On 16/04/13 22:20, Andy McKenzie wrote:

> For instance:  output of running print_r on a very short dictionary from
> PHP:
>
> Array
> (
>      [key3] => thing3
>      [key2] => thing2
>      [key1] => thing1
> )
>
> And running pprint on the same dict in Python:
>
> {'key1': 'thing1', 'key2': 'thing2', 'key3': 'thing3'}
>
>
> I finally decided that a good project would be building a quick function
> that recreates the print_r function, and I got that working.  New
> function output, in Python:
>
> (
>      [key3] => thing3
>      [key2] => thing2
>      [key1] => thing1
> )


You should probably use {} instead of () as the delimiter to indicate 
that the thing is a dictionary and not a tuple. but otherwise that's a 
good starter project.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list