Question about indentation and bugs

Tim Peters tim.one at home.com
Fri Aug 24 18:52:20 EDT 2001


[Terry Reedy]
> *NOT* using {} redundantly for blocking frees {} for use as dictionary
> delimiters.  Anyone who suggests using {} for structure should be
> asked how they would write dictionary literals!

Easy!  Instead of, e.g.,

    if 1:
        x = {1: 'a', 2: {'b': 3}}
        print x

we'll rehabilitate indentation for dict literals:

    if 1 {
 x =
     1: 'a'
     2:
         'b': 3
  print x
 }

IOW, the body of a dict literal needs to be indented relative to the
preceding stmt, and the stmt following a dict literal needs to be dedented.
Apart from those rules, you can enjoy the readability afforded by curly
braces to start stmts wherever the hell you feel like, damn it <wink>.





More information about the Python-list mailing list