Allowing Arbitrary Indentation in Python
Grant Edwards
grante at visi.com
Tue Dec 18 17:28:42 EST 2007
On 2007-12-18, Sam <L33tminion at gmail.com> wrote:
> 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()
And you think that example is an argument in _favor_ of what
you propose?
> Do such rules make sense?
IMO, no.
> Is there any way to make code work that way in Python?
no.
> Should there be?
God no.
Code should work the way it looks and look the way it works.
Changing the language in order to allow authors to mislead
readers is a bad thing.
> Does that make this sort of code more or less readable?
You must be joking.
--
Grant Edwards grante Yow! I joined scientology
at at a garage sale!!
visi.com
More information about the Python-list
mailing list