473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Can i use this script as a python evaluator?


<code>
#! /bin/sh
python -c "import sys;exec(sys.stdin)"
</code>

Emacs has a function `shell-command-on-region', which takes region as
input for the evaluator (script above), and output its result. I have
tried and found it works, is there any problems for this, or any other
better solution for it? Thanks.
Oct 20 '08 #1
4 1249
Bruno Desthuilliers <bd*****************@free.quelquepart.frwrites:
Peter Wang a écrit :
><code>
#! /bin/sh
python -c "import sys;exec(sys.stdin)"
</code>

Emacs has a function `shell-command-on-region', which takes region as
input for the evaluator (script above), and output its result. I have
tried and found it works, is there any problems for this, or any other
better solution for it? Thanks.
If your problem is to eval a region of a python buffer and output the
result to another buffer, then python-mode.el (the one that comes with
Python, not the python.el bundled with recent emacs versions) already
know how to do so.
Yes, I want eval a region, but likely not a python buffer, for example,
in a *w3m* buffer.
>
Else please explain what you're trying to do ?
--
http://mail.python.org/mailman/listinfo/python-list
Oct 21 '08 #2
#! /bin/sh
python -c "import sys;exec(sys.stdin)"
I know this isn't your question, but I think you could write that more
cleanly with:

#!/usr/bin/python
import sys
exec(sys.stdin)
Oct 21 '08 #3
Nathan Seese <un********@lavabit.comwrites:
>#! /bin/sh
python -c "import sys;exec(sys.stdin)"

I know this isn't your question, but I think you could write that more
cleanly with:

#!/usr/bin/python
import sys
exec(sys.stdin)
thanks.
What's the difference between this and mine?

I think what i need actually is a python function like
`file_get_contents' in php:)
--
http://mail.python.org/mailman/listinfo/python-list
Oct 21 '08 #4
On Tue, 21 Oct 2008 11:22:56 +0800, Peter Wang wrote:
Nathan Seese <un********@lavabit.comwrites:
>>#! /bin/sh
python -c "import sys;exec(sys.stdin)"

I know this isn't your question, but I think you could write that more
cleanly with:

#!/usr/bin/python
import sys
exec(sys.stdin)

thanks.
What's the difference between this and mine?
Yours launches an new shell, which then calls python, which then executes
whatever it finds in stdin as Python code.

The second one just launches Python directly.
I think what i need actually is a python function like
`file_get_contents' in php:)

I think that would be:

contents = open(filename).read()


--
Steven
Oct 21 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Vanish92 | last post by:
I created a dll to evaluate a home-grown data type. I added an entry in the autoexp.dat pointing to my dll for the data type. When I try to debug it (_Debug compile), I have the expression...
0
by: Vanish92 | last post by:
I created a dll to evaluate a home-grown data type. I added an entry in the autoexp.dat pointing to my dll for the data type. When I try to debug it (_Debug compile), I have the expression...
0
by: palani12kumar | last post by:
I had some problem regarding creating an expression evaluator using C. i've have not got an clear idea about the "expression Evaluator". Can you please tell me, what's an expression evaluator? and...
11
by: Jordan | last post by:
I am trying to rewrite some C source code for a poker hand evaluator in Python. Putting aside all of the comments such as just using the C code, or using SWIG, etc. I have been having problems...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.