On Tue, Apr 16, 2013 at 7:39 PM, Alan Gauld <alan.ga...@btinternet.com>wrote:
> 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. > > Good idea. I went with () because I was just trying to duplicate the output in PHP. Now that I've got that, I can start thinking about improvements. Varying the punctuation to match the type would probably be a good idea. Thanks, Andy
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor