473,473 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

deleting the terminal prompt?

Dear all,

I just noticed the following behavior when I run

import os
import sys
import readline

histfile = os.path.join(os.environ["HOME"], ".pyhist")

try:
readline.read_history_file(histfile)
except IOError:
pass

import atexit
atexit.register(readline.write_history_file, histfile)
del os, histfile

while cmd != "":

sys.stdout.write("prompt: ")
cmd = raw_input()

# at this point it studies the contents of cmd and decides what to
do next.

However, if the user simply presses Tab followed by a backspace s/he
effectively makes the prompt disappear. Is there a way to prevent this
from happening?
Thanks for any help,

Mack

Jul 19 '05 #1
3 1196
On 15 May 2005 16:32:57 -0700, "MackS" <ma***********@hotmail.com>
declaimed the following in comp.lang.python:

while cmd != "":

sys.stdout.write("prompt: ")
cmd = raw_input()

# at this point it studies the contents of cmd and decides what to
do next.

However, if the user simply presses Tab followed by a backspace s/he
effectively makes the prompt disappear. Is there a way to prevent this
from happening?
What behavior does...

while cmd != "":
cmd = raw_input("prompt: ")

.... give you?

-- ================================================== ============ <
wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
================================================== ============ <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.netcom.com/> <

Jul 19 '05 #2
Thanks, Dennis, that solved it.

Cheers

Mack

Dennis Lee Bieber wrote:
On 15 May 2005 16:32:57 -0700, "MackS" <ma***********@hotmail.com>
declaimed the following in comp.lang.python:

while cmd != "":

sys.stdout.write("prompt: ")
cmd = raw_input()

# at this point it studies the contents of cmd and decides what to do next.

However, if the user simply presses Tab followed by a backspace s/he effectively makes the prompt disappear. Is there a way to prevent this from happening?

What behavior does...

while cmd != "":
cmd = raw_input("prompt: ")

... give you?

--
> ================================================== ============ <
> wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
> wu******@dm.net | Bestiaria Support Staff <
> ================================================== ============ <
> Home Page: <http://www.dm.net/~wulfraed/> <
> Overflow Page: <http://wlfraed.home.netcom.com/> <


Jul 19 '05 #3
On 15 May 2005 18:01:18 -0700, "MackS" <ma***********@hotmail.com>
declaimed the following in comp.lang.python:
Thanks, Dennis, that solved it.
Good to know.

I'll confess, I hadn't double-checked the behavior myself -- I
was hoping that the coders of raw_input() were smart enough to ensure
that the prompt string that it takes was refreshed if the user ran
back-spaces/deletes/etc. I jumped on that since it looked like you
hadn't realized it /had/ a prompt argument, and the disjoint write/input
sequence has no common state information.

-- ================================================== ============ <
wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
================================================== ============ <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.netcom.com/> <

Jul 19 '05 #4

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

Similar topics

2
by: Brendan zerofor0je | last post by:
Hello, I've written a small reverse-telnet client that connects to a server that handles all the clients. the reverse telnet node ( whitch i will refer to as rtn from now on) works by opening...
20
by: Joel Hedlund | last post by:
Hi all! I use python for writing terminal applications and I have been bothered by how hard it seems to be to determine the terminal size. What is the best way of doing this? At the end I've...
3
by: Kimera.Kimera | last post by:
I'm trying to write a program in VB.net 2003 that basically deletes all files, folders, sub-folders and sub-sub folders (etc). The program is simply for deleting the Windows/Temp folder contents,...
3
by: zubin | last post by:
i want to take input at the screen and at the same time flash the output on to the terminal (coming from some other process)...how do i go about it? the interface should look something like...
5
by: Stephen_B | last post by:
This doesn't seem to work in a dos terminal at the start of a script: from os import popen print popen('clear').read() Any idea why not? Thanks. Stephen
8
by: asgarde | last post by:
hello, I'm new in Python and i would like to use Pexpect to execute a root command (i want to mount via a Pyhton script a drive) so that's my script for the moment : from os import *...
1
by: linksterman | last post by:
I am currently writing a server based IM type of a program for my java class. The problem is that the client (which runs in a terminal) blocks all incoming traffic as it waits for you to type a...
9
by: bmerlover | last post by:
I would like to know how to prompt the user for an input on the terminal. I have a print statement which asks for 3 choices and use <STDIN> to prompt the user for an input. This code works perfectly...
3
Frinavale
by: Frinavale | last post by:
The windows key is rather useless in Linux. I would love to bind the windows key to open a terminal window (since I'm in the habit of hitting the windows key + r to open the run prompt so that I...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.