.pyc from stdin?

Discussion in 'Python' started by Shay Telfer, Oct 7, 2009.

  1. Shay Telfer

    Shay Telfer Guest

    Hi...

    It seems that python will accept a .py file piped from stdin, but not a
    ..pyc file (and there don't seem to be any flags to allow this). Am I
    missing something?

    Eg

    cat blah.py | python

    works, but

    cat blah.pyc | python

    doesn't. (If you're wondering why anyone would do this it's because I'm
    actually intending to use curl rather than cat :)

    Thanks,
    Shay
    Shay Telfer, Oct 7, 2009
    #1
    1. Advertising

  2. Shay Telfer

    lallous Guest

    Hello Shay,

    "Shay Telfer" <> wrote in message
    news:...
    > Hi...
    >
    > It seems that python will accept a .py file piped from stdin, but not a
    > .pyc file (and there don't seem to be any flags to allow this). Am I
    > missing something?
    >
    > Eg
    >
    > cat blah.py | python
    >
    > works, but
    >
    > cat blah.pyc | python
    >


    Try for example: python -c "import blah"


    > doesn't. (If you're wondering why anyone would do this it's because I'm
    > actually intending to use curl rather than cat :)
    >


    The former works because the Python interpreter understands python syntax,
    and when you (in the latter case) provide the interpreter a pyc file it
    surely won't work because it does not understand those compiled bytes just
    like that....

    --
    Elias
    lallous, Oct 8, 2009
    #2
    1. Advertising

  3. Shay Telfer

    lallous Guest

    Hello Shay,

    "Shay Telfer" <> wrote in message
    news:...
    > Hi...
    >
    > It seems that python will accept a .py file piped from stdin, but not a
    > .pyc file (and there don't seem to be any flags to allow this). Am I
    > missing something?
    >
    > Eg
    >
    > cat blah.py | python
    >
    > works, but
    >
    > cat blah.pyc | python
    >


    Try for example: python -c "import blah"


    > doesn't. (If you're wondering why anyone would do this it's because I'm
    > actually intending to use curl rather than cat :)
    >


    The former works because the Python interpreter understands python syntax,
    and when you (in the latter case) provide the interpreter a pyc file it
    surely won't work because it does not understand those compiled bytes just
    like that....

    --
    Elias
    lallous, Oct 8, 2009
    #3
  4. Shay Telfer

    lallous Guest

    Hello Shay,

    "Shay Telfer" <> wrote in message
    news:...
    > Hi...
    >
    > It seems that python will accept a .py file piped from stdin, but not a
    > .pyc file (and there don't seem to be any flags to allow this). Am I
    > missing something?
    >
    > Eg
    >
    > cat blah.py | python
    >
    > works, but
    >
    > cat blah.pyc | python
    >


    Try for example: python -c "import blah"


    > doesn't. (If you're wondering why anyone would do this it's because I'm
    > actually intending to use curl rather than cat :)
    >


    The former works because the Python interpreter understands python syntax,
    and when you (in the latter case) provide the interpreter a pyc file it
    surely won't work because it does not understand those compiled bytes just
    like that....

    --
    Elias
    lallous, Oct 8, 2009
    #4
    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. Johnathan Doe

    peek at stdin, flush stdin

    Johnathan Doe, May 15, 2004, in forum: C Programming
    Replies:
    5
    Views:
    24,970
    Chatoyer
    May 17, 2013
  2. Charlie Zender

    Reading stdin once confuses second stdin read

    Charlie Zender, Jun 19, 2004, in forum: C Programming
    Replies:
    6
    Views:
    787
    Dan Pop
    Jun 21, 2004
  3. Ben
    Replies:
    2
    Views:
    1,344
    jacob navia
    Aug 29, 2009
  4. Terry Cooper
    Replies:
    7
    Views:
    425
    Janos Sebok
    Jun 9, 2009
  5. Stefano Sabatini
    Replies:
    6
    Views:
    292
    Stefano Sabatini
    Jul 29, 2007
Loading...

Share This Page