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

Steve Holden sholden at holdenweb.com
Thu Apr 17 09:20:09 EDT 2003


"Grant Edwards" <grante at visi.com> wrote in message
news:3e9dca74$0$170$a1866201 at newsreader.visi.com...
> 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...
>
Now try putting an import before the "for" statement ...

regards
--
Steve Holden                                  http://www.holdenweb.com/
How lucky am I?      http://www.google.com/search?q=Steve+Holden&btnI=1
Python Web Programming                 http://pydish.holdenweb.com/pwp/



> --
> 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