On 31/07/2013 14:55, Chris Angelico wrote:
[...]


Since the braced version won't run anyway, how about a translation like this:

def foo():
     print("""Hello,
world!""")
     for i in range(5):
         foo()
     return 42

-->

0-def foo():
4-print("""Hello,
0-world!""")
4-for i in range(5):
8-foo()
4-return 42

That's a simple translation that guarantees safe round-tripping, and
you can probably do it with a one-liner fwiw... let's see...

# Assumes spaces OR tabs but not both
# Can't see an easy way to count leading spaces other than:
# len(s)-len(s.lstrip())

How about len(s.expandtabs()) - len(s.lstrip()) instead?
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to