Re: Pythonic list/tuple/dict layout?

2009-02-01 Thread Aahz
In article 871vur39k7@benfinney.id.au, Ben Finney bignose+hates-s...@benfinney.id.au wrote: I actually use this style: foo = { 0: 'spam', 1: 'eggs', 2: 'beans', } because that makes it clear that *all* the indented lines are a continuation of the same

Pythonic list/tuple/dict layout?

2009-01-25 Thread Akira Kitada
Hi, There is more than one way to write a list/tuple/dict in Python, and actually different styles are used in standard library. As a hobgoblin of little minds, I rather like to know which style is considered Pythonic in the community. I collected common layout from existing code and pasted them

Re: Pythonic list/tuple/dict layout?

2009-01-25 Thread Stephen Hansen
and pasted them below. My vote would go to d1. How about yours? Whatever reads best within the context of the specific code is Pythonic. -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonic list/tuple/dict layout?

2009-01-25 Thread Dan Bishop
On Jan 25, 2:18 am, Akira Kitada akit...@gmail.com wrote: Hi, There is more than one way to write a list/tuple/dict in Python, and actually different styles are used in standard library. As a hobgoblin of little minds, I rather like to know which style is considered Pythonic in the

Re: Pythonic list/tuple/dict layout?

2009-01-25 Thread Akira Kitada
Wow! A Python debate over curly brace placement! Imagine that! PEP8 even deals with tabs vs spaces, where to put a blank line, etc :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonic list/tuple/dict layout?

2009-01-25 Thread Michael Iatrou
When the date was Sunday 25 January 2009, Akira Kitada wrote: There is more than one way to write a list/tuple/dict in Python, and actually different styles are used in standard library. I would vote for d1, but I don't think that this is more pythonic, I just consider it more clean,

Re: Pythonic list/tuple/dict layout?

2009-01-25 Thread Ben Finney
Akira Kitada akit...@gmail.com writes: I collected common layout from existing code and pasted them below. My vote would go to d1. How about yours? If there is consensus on this, that might be worth being included in PEP 8. Thanks, d1 = { 0: ham, 1: jam, 2: spam,

Re: Pythonic list/tuple/dict layout?

2009-01-25 Thread Steven D'Aprano
On Sun, 25 Jan 2009 17:18:28 +0900, Akira Kitada wrote: Hi, There is more than one way to write a list/tuple/dict in Python, and actually different styles are used in standard library. As a hobgoblin of little minds, I rather like to know which style is considered Pythonic in the

Re: Pythonic list/tuple/dict layout?

2009-01-25 Thread Akira Kitada
BTW, there's no need to use such large examples. Three items per dict would be sufficient to illustrate the styles, using ten items doesn't add anything useful to the discussion. I worried to be told 'you can make it in a line like {ham: jam, spam: alot}' ;) --

Re: Pythonic list/tuple/dict layout?

2009-01-25 Thread Akira Kitada
These are the only two that follow PEP 8; the others don't have four-space indent levels. In those examples, the following sentence in PEP 8 would be applied. Make sure to indent the continued line appropriately. I actually use this style: foo = { 0: 'spam', 1: 'eggs',

Re: Pythonic list/tuple/dict layout?

2009-01-25 Thread Rhamphoryncus
d1 -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonic list/tuple/dict layout?

2009-01-25 Thread Mark Wooding
Akira Kitada akit...@gmail.com writes: I collected common layout from existing code and pasted them below. My vote would go to d1. How about yours? It seems that I use both d1 and d4, though in both cases I omit the trailing commas. I use d1 when each item is on a separate line, and d4 when