TABs (was: Waffling between Python and Ruby)

Just van Rossum just at letterror.com
Mon Jun 19 11:22:00 EDT 2000


I wrote:
[something about spaces for indentation with proportional fonts.]

Mark Hammond wrote:
>I agree 100% with your sentiments!
>
>But Im not sure I understand the above.

Oops, I snipped it...

>If you indent with leading spaces, then presumably all leading spaces will
>be rendered in the same font.  So even for proportional fonts, the code
>should align correctly with spaces or tabs.

Yeah, it'll be correct, but my point is that the amount of (visual)
indentation then depends on the font instead of a user preference. To me
this makes the mere idea of having to choose how many spaces to use for
indentation complete nonsense. (In my MacPython IDE the user can choose
between the spaces and pixels as a visual size unit when setting the
indentation level...)

>For alignment of anything other than the first non-space character (eg,
>attempting to align a table, or a parameter list that spans
>multiple-lines, for example), then if you use tabs, you are back in the
>same position that started this thread - you are making some assumption
>about the location of the tab-stops, or an assumption about the width of
>the previous characters.

Yep.

>So I simply can not see a solution for ensuring _all_ code is visually
>indented correctly when using purely tabs with a proportional font.

True.

>Let me know if I am wrong - I use a proportional font myself, and added a
>quick toggle-between-fixed-and proportional command to Pythonwin purely to
>get around this problem - Im forced to switch to fixed-point and using
>spaces for non-leading indents...

That's often what I do, too... However, I never align multi-line arg lists
the way pymode (and I think IDLE/PythonWin) does it; I always indent
continued arg lines with two extra tabs. Not only because of the problem
you describe but also because I like it better that way. Most of the time
when the arguments don't fit comfortable on a single line, I don't split
them up by using a single line per argument, but rather have a bunch of
args per line. This split is rather arbitrary and to me aligning the Nth
argument with the first doesn't make a whole lot of sense to begin with.

I also try to avoid aligning comments like this:

	a = 12              # a comment
	yabbadabbadoo = 13  # another comment

by doing

	# a comment
	a = 12
	# another comment
	yabbadabbadoo = 13

Unless you comment every single line this is quite doable (and likable!).

Tables indeed remain a problem with proportional fonts...

Just






More information about the Python-list mailing list