Author Topic: Beautify Python, Beautify Django Templates  (Read 3955 times)

tlholaday

  • Community Member
  • Posts: 15
  • Hero Points: 2
  • Text text wonderful text
Beautify Python, Beautify Django Templates
« on: November 17, 2008, 03:11:36 PM »
I want to beautify Python e.g. ....

a = [((function1(x[0]),(function2(x[1])),"red" if x[3]>.5 else "blue") for x in container.results() if x[2]]

... becomes ...


a = [
    (
        (
            function1(x[0]),
            function2(x[1]),
        ),
        "red" if x[3] > .5 else "blue"
    )
    for x in container.results() if x[2]
    ]


... but I suspect beautifying Python is nontrivial.

I also want to beautify Django templates e.g. ...


<body><div class="{{ theclass }}">{% if isKnown %} Welcome back! {% else %} Who are you? {% endif %}</div></body>


... becomes ...


<body>
    <div
class="{{ theclass }}">
        {% if isKnown %}
            Welcome back!
        {% else %}
            Who are you?
        {% endif %}
    </div>
</body>



Also Yaml and CSS.  Why yes I am working on a Google Application Engine project, how did you guess?