You are not logged in.

#1 2005-12-11 17:29:40

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Python inside bash inside Python

check this out:

 dusty:~ $ python
Python 2.4.2 (#1, Nov 12 2005, 10:57:47) 
[GCC 4.0.3 20051006 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.system('bash')
dusty:~ $ python
Python 2.4.2 (#1, Nov 12 2005, 10:57:47) 
[GCC 4.0.3 20051006 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>                    
dusty:~ $ exit
0
>>> 

Now, the question is, can I make python my normal shell instead of bash?  Gonna work on that..... Imagine, you could just call 'import magnum' and there's your editor.... and stuff..... woot.

Dusty

Offline

#2 2005-12-11 23:23:52

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Python inside bash inside Python

I think there was a project recently to make a python enabled shell - bourne shell compatible with python builtins... I know there's a perl shell like that

Offline

#3 2005-12-12 00:31:57

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Offline

#4 2005-12-16 16:35:53

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Python inside bash inside Python

Does this help? I don't know if it's a full-on shell or just an interactive python interp:
http://geophile.com/osh/index.html

Offline

#5 2005-12-16 16:55:51

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,893
Website

Re: Python inside bash inside Python


Mr Green

Offline

#6 2005-12-16 17:59:24

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Python inside bash inside Python

phrakture wrote:

Does this help? I don't know if it's a full-on shell or just an interactive python interp:
http://geophile.com/osh/index.html

Hmm, it looks like this is actually a shell tool... allowing you to make lambda expressions awk style:

 $ find . | osh ^ f 's: path(s)' $

It looks rather interesting though... not sure if I like the enforced '^blah$' delims though...

Offline

#7 2005-12-16 23:12:34

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Python inside bash inside Python

Hey, these are really cool..... would be so cool if one of my good friends with time on their hands would make a couple packages for me to experiemnet with sometime...  when I have free time away from this utter bullshit that is driving me to homocidal thoughts....


Dusty

Offline

#8 2005-12-16 23:20:43

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Python inside bash inside Python

I thought IPython was just a replacement for the "$ python" interpreter, when mucking around command line style?

Offline

#9 2005-12-16 23:47:08

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Python inside bash inside Python

I think so but I'm thinking of using the regular interpreter as a shell replacement, so an enhanced one mich be cooler to play with

as if I had time for cool stuff like this sad

Dusty

Offline

#10 2005-12-17 00:49:40

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Python inside bash inside Python

Dusty wrote:

I think so but I'm thinking of using the regular interpreter as a shell replacement, so an enhanced one mich be cooler to play with

as if I had time for cool stuff like this sad

Dusty

make a package that has functions like 'ls' and whatnot - "from shellutils import *"

Offline

#11 2005-12-17 00:51:44

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Python inside bash inside Python

yeah, like that. I have some neat ideas... python functions for common apps, python string processing instead of grep.... python python python..... ooooooh.....

Dusty

Offline

#12 2005-12-19 04:49:29

awalk
Member
From: Perth, Western Australia
Registered: 2005-02-14
Posts: 40

Re: Python inside bash inside Python

A shell with close integration with Python would be awesome. I'd been thinking about this a while back, after hearing all about Monad.

In terms of use as a replacement shell, I don't think simply having a bunch of packages would be enough. What if you want to do redirection? I know 'print' can redirect to files, but it's not nearly as nice as simply writing "> filename". But then, if you have a custom syntax, you're likely to murder some of Python's features.

One of the cool things you could do (as with Monad), is returning objects from a program, rather than just a return code.

If anyone has any bright ideas, I'd be interested to work on something like this.

Offline

Board footer

Powered by FluxBB