do python's nifty indentation rules spell the death of one-liners?

Greg Ewing (using news.cis.dfn.de) ckea25d02 at sneakemail.com
Wed Apr 16 00:05:07 EDT 2003


Gerhard Häring wrote:
> Try:
> 
> python -c """
> print 2
> for i in (1, 4):
>     print i
> """
> 
> It seems to work under a bash script at least.

I just tried this in a Makefile, and it seems to work:

all:
	python -c '\
	for i in range(10):\
	 print i'

(There's a tab at the beginning of each line, and
*no* extra whitespace after that apart from what
Python needs for indentation.)

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg





More information about the Python-list mailing list