[python-advocacy] example code

Tennessee Leeuwenburg tleeuwenburg at gmail.com
Fri Nov 13 00:03:06 CET 2009


Just another option...

print "Python is" + ', '.join([index + ', ' + each for each in python])

On Fri, Nov 13, 2009 at 4:20 AM, Aahz <aahz at pythoncraft.com> wrote:

> On Thu, Nov 12, 2009, Ray Allen wrote:
> >
> > # Create  list
> > python = ["Easy to read",
> > "Fast to code",
> > "Quick to learn",
> > "Modular and object oriented"]
>
> AFAIK, almost everyone indents multi-line expressions.  There are several
> ways to do it, this is my preferred version:
>
> python = [
>    "Easy to read",
>    "Fast to code",
>    "Quick to learn",
>     "Modular and object oriented",
>    ]
>
> The reason I prefer this is because it makes it easy to edit the list,
> specifically including the trailing comma on the last element.  (E.g.
> it's much easier to delete the first list element than when you put it
> next to the opening bracket -- just delete the line.)  It's also easy to
> read because the beginning and end of the list are highly visible.  I
> prefer to indent only one level rather than matching up the beginning and
> ending brackets because that gives more line length to the list contents.
> --
> Aahz (aahz at pythoncraft.com)           <*>
> http://www.pythoncraft.com/
>
> [on old computer technologies and programmers]  "Fancy tail fins on a
> brand new '59 Cadillac didn't mean throwing out a whole generation of
> mechanics who started with model As."  --Andrew Dalke
> _______________________________________________
> Advocacy mailing list
> Advocacy at python.org
> http://mail.python.org/mailman/listinfo/advocacy
>



-- 
--------------------------------------------------
Tennessee Leeuwenburg
http://myownhat.blogspot.com/
"Don't believe everything you think"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/advocacy/attachments/20091113/58f148c6/attachment.htm>


More information about the Advocacy mailing list