Python from the command line (was: Choosing Perl/Python for my particular niche)

Discussion in 'Perl Misc' started by Cameron Laird, Apr 1, 2004.

  1. In article <>,
    Fred Ma <> wrote:
     
    Cameron Laird, Apr 1, 2004
    #1
    1. Advertising

  2. Cameron Laird

    Fred Ma Guest

    Re: Python from the command line (was: Choosing Perl/Python for myparticular niche)

    Cameron Laird wrote:
    >
    > In article <>,
    > Fred Ma <> wrote:
    > .
    > .
    > .
    > >Perl/sed. About invoking Perl as part of a simple command in a
    > >pipeline, I mean that one doesn't even have to write a script for it,
    > >similar to sed
    > >
    > > Command1 | sed -e Expression1 -e Expression2 ... | Command_N
    > >
    > >This might also be possible in Python, in which case so much the better.
    > >I'll find out (or someone might answer in a follow-up post). Thanks

    > .
    > .
    > .
    > # python -c "print 3 + 5"
    > 8


    I was 99.99% sure that it was possible (heck, if tcsh and bash can do
    it, python surely can). It's a little easier to squish it into a simple
    command in a pipeline for a terse/compact "language" e.g. sed. On a
    side-note, I've abused sed before by embedded sed scripts into bash
    scripts without actually writing the sed script:

    Bash_Command | \
    sed \
    -e 'Expression1' \
    -e 'Expression2' \
    -e 'Conditional1 {' \
    -e 'Body_of_Conditional1' \
    -e 'More_of_Body' \
    -e '}' \
    | More_Bash_Commands

    Not that I want to do everything in sed, of course. And for
    perl/python, there is probably not much reason to mix commands
    with bash, since (unlike sed) they have the shell functionality.

    I've put in a request to my sysadmin to install python. The
    way to get hooked on it is to start small, with mundane tasks
    (same as with any new shell, I suppose). If it doesn't get
    installed due to lack of priority, I can always get it
    bundled with my next cygwin update. Cygwin is an absolute
    blessing. Everything comes prebuilt (lots of stuff) and
    you have superuser priveleges, as well as simultaneous
    access to Windows. Just as long as your HDD isn't FAT
    (that prevents chmod from working).

    But I digress.....

    Fred

    --
    Fred Ma
    Dept. of Electronics, Carleton University
    1125 Colonel By Drive, Ottawa, Ontario
    Canada, K1S 5B6
     
    Fred Ma, Apr 1, 2004
    #2
    1. Advertising

  3. Re: Python from the command line (was: Choosing Perl/Python for myparticular niche)

    In article <>,
    Fred Ma <> wrote:
     
    Cameron Laird, Apr 1, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Cameron Laird
    Replies:
    3
    Views:
    402
    Fred Ma
    Apr 1, 2004
  2. J Krugman

    A wide open niche in Perl publishing...

    J Krugman, Feb 15, 2005, in forum: Perl Misc
    Replies:
    8
    Views:
    124
    Charlton Wilbur
    Feb 17, 2005
  3. Replies:
    2
    Views:
    168
    Tad McClellan
    Mar 26, 2005
  4. Ting Wang
    Replies:
    3
    Views:
    209
    Paul Lalli
    Dec 13, 2005
  5. jeniffer
    Replies:
    6
    Views:
    1,023
Loading...

Share This Page