Allowing Arbitrary Indentation in Python

Sam L33tminion at gmail.com
Tue Dec 18 17:16:59 EST 2007


A friend of mine is picking up some Python and is frustrated by
Python's indentation rules (http://greatbiggary.livejournal.com/
260460.html?thread=1835884#t1835884).  Personally, I've never had any
issues with Python's ways of indentation, but that conversation got me
thinking about the issue.

Consider the following indentation rules:
1. Blocks begin with a line ending in ":"
2. A line on the same indentation level or lower ends a block.

Under those rules, this would work:
layouts = ['column', 'form', 'frame']
cmds.window(t='gwfUI Builder')
cmds.paneLayout(configuration='vertical3', ps=((1, 25, 100), (3, 20,
100)))
    cmds.paneLayout(configuration='horizontal2')
        cmds.frameLayout(l='Layouts')
            cmds.scrollLayout(cr=True)
                cmds.columnLayout(adj=True, cat=('both', 2))
                    for i in layouts:
	                cmds.button(l=i)
                cmds.setParent('..')
            cmds.setParent('..')
        cmds.setParent('..')
    cmds.setParent('..')
cmds.setParent('..')
cmds.showWindow()

Do such rules make sense?  Is there any way to make code work that way
in Python?  Should there be?  Does that make this sort of code more or
less readable?

P.S. I'm definitely not looking for a tabs vs. spaces flamewar here.
That's a different issue.



More information about the Python-list mailing list