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

Grant Edwards grante at visi.com
Wed Apr 16 17:26:12 EDT 2003


In article <a8b7f07a.0304161314.361a80fa at posting.google.com>, A. Lloyd Flanagan wrote:

>> > python << DONE
>> > print 2
>> > for i in (1,4):
>> >      print i
>> > DONE
>> 
>> But how do you do it in a Makefile?
> 
> Err.  Put it in a script file, and call the script file from make?

That's one solution, but now you've got another file to keep
track of.

> I tried sticking it in a Makefile, can't get it to work.  So far.

How 'bout this:

all:
        python2 -c $$'for i in range(5):\n print i\n\n'
        

I think that the $'<string>' notation is a bash-ism.  If that's
a problem, then

        echo -e "for i in range(5):\n print i\n\n" | python2
        
should also work.  Adjust the echo options appropriately to get
interpretation of \n to work.

There may be other ways to get Make to interpret \n in a
string...

-- 
Grant Edwards                   grante             Yow!  I want to dress you
                                  at               up as TALLULAH BANKHEAD and
                               visi.com            cover you with VASELINE and
                                                   WHEAT THINS...




More information about the Python-list mailing list