.pyc from stdin?

S

Shay Telfer

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
 
L

lallous

Hello Shay,

Shay Telfer said:
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....
 
L

lallous

Hello Shay,

Shay Telfer said:
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....
 
L

lallous

Hello Shay,

Shay Telfer said:
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....
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top