[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Tabs v.s. spaces

On Tue, Nov 18, 2003 at 11:32:36AM -0800, Tom wrote:
> Serious #1:
> *It looks like multi-line method invocations require parenthesis to be
> indented at the paren level.  Sometimes that's useful, but often I
> like to pack arguments tighter than that and indent only once on
> subsequent lines:
>     myreallylongmethodname(bar, bar, bar, bar, bar,
>       baz, baz, baz);
>     myreallylongmethodname(bar, bar, bar, bar, bar,
>                            baz, baz, baz);

No, this is not true.  You are describing implicit line joining, which
is described in the Library Reference[1] Section 2.1.3[2].

	"Expressions in parentheses, square brackets or curly braces can
	be split over more than one physical line without using
	backslashes...  The indentation of the continuation lines is not
	important.  Blank continuation lines are allowed."

Besides, you don't NEED ';' in Python to end a single statement.

> Serious #2:
> Multiple statements per line in diagnostic code and error flow control.
> The operant value in both these cases is some code is relatively 
> unimportant to the main flow of the program and doesn't warrant gobs of 
> space.  "Real" code should be indented like Python, but if everything is 
> "proper", "important" code gets lost in a bunch of scaffolding.
> Obiviously high equality code should be simple, but sometimes other 
> values weigh slightly higher than writing perfect code, and flexibility 
> is useful.

You can combine statements (Compound Statements[3]) on a single line
with the ';' character...

	print 'ERROR: You are mistaken'; sys.exit(1)

Or control flow constructs...

	if test: if test2: print x

Which could just as easily be written

	if test:
		if test2:
			print x
> Light-hearted:
> Sometimes I just feel like writing crappy multi-line, write-only code
> because it's not intended to change the world, and I want to see it
> all on the screen at once.  Many real-world tasks are like this.


1. http://www.python.org/doc/current/ref/
2. http://www.python.org/doc/current/ref/implicit-joining.html
3. http://www.python.org/doc/current/ref/compound.html

Chad Walstrom <chewie@wookimus.net>           http://www.wookimus.net/
           assert(expired(knowledge)); /* core dump */

Attachment: pgpHOb516k2j1.pgp
Description: PGP signature

Reply to: