Bash shell to Python shell?

E

edwithad

I am sure you have not read a question this basic in some time, but I
am curious. Using Linux I open a terminal window and type: python.

Does Bash Shell go away and to become a Python Shell, or is it still a
Bash Shell with Python running inside? Thanks in advance.
 
C

Chris Rebert

I am sure you have not read a question this basic in some time, but I am
curious. Using Linux I open a terminal window and type: python.

Does Bash Shell go away and to become a Python Shell, or is it still a Bash
Shell with Python running inside? Thanks in advance.

The latter. Press Ctrl+D or enter exit() or quit() to exit Python and
return to bash.

Cheers,
Chris
 
N

Ned Deily

I am sure you have not read a question this basic in some time, but I
am curious. Using Linux I open a terminal window and type: python.

Does Bash Shell go away and to become a Python Shell, or is it still a
Bash Shell with Python running inside? Thanks in advance.

See for youself:

$ ps
PID TTY TIME CMD
17478 pts/0 00:00:00 bash
17571 pts/0 00:00:00 ps

$ python
Python 2.5.4 (r254:67916, Feb 17 2009, 20:16:45)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information. PID TTY TIME CMD
17478 pts/0 00:00:00 bash
17572 pts/0 00:00:00 python
17573 pts/0 00:00:00 sh
17574 pts/0 00:00:00 ps
0
So you can see that the top-level shell (process id 17478) starts new
child processes to run other programs (17571 for the ps in the first
example, 17572 for python in the second), just as the python os.system
function starts a new shell (17573, a default /bin/sh) to process the
'ps' argument string passed to it and that shell starts another process
(17574) to run 'ps'.

For a more detailed explanation of what's going on, see, for example:

http://tldp.org/HOWTO/Unix-and-Internet-Fundamentals-HOWTO/running-progra
ms.html
 
G

Grant Edwards

The latter. Press Ctrl+D or enter exit() or quit() to exit Python and
return to bash.

Bash doesn't really "go away". It's still there, it just hands
over the terminal to the python interpreter and then sits and
waits for the python interpreter to exit. At that point the
Bash shell (the same one as before) resumes.
 
G

garabik-news-2005-05

Chris Rebert said:
The latter. Press Ctrl+D or enter exit() or quit() to exit Python and
return to bash.

Or, if you prefer the bash shell to be replaced with the python, just type:
exec python

--
-----------------------------------------------------------
| Radovan Garabík http://kassiopeia.juls.savba.sk/~garabik/ |
| __..--^^^--..__ garabik @ kassiopeia.juls.savba.sk |
-----------------------------------------------------------
Antivirus alert: file .signature infected by signature virus.
Hi! I'm a signature virus! Copy me into your signature file to help me spread!
 

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

No members online now.

Forum statistics

Threads
474,470
Messages
2,571,807
Members
48,797
Latest member
PeterSimpson
Top