python login shell?
7 posts
My nephew, who finally got a long promised raspi, remarked that it would be neat if it "powered up in python mode" -- sort of like BBC micro and Basic! Has anyone tried using /usr/bin/python as their login shell (or even bypass login completely and immediately drop the user in python shell)? How well did that work? How easy it is to edit code, debug, display graphical output etc.? Thanks
- Posts: 255
- Joined: Sun Sep 25, 2011 1:25 am
I suspect you will not find an editor that you can use from inside Python. You could do something like
Also I haven't come across a "NEW" command in Python to forget everything and start again. Although I suppose logging out and back in is easy enough.
It would be "easily" possible to create a new Python environment with the required commands built in to it, all the hooks are there. You would need to use an existing editor such as nano, (just because writing screen-based editors is not trivial,) but that's easy. It could be an interesting project for you and/or your nephew.
- Code: Select all
import os
os.system("nano file.py")
- Code: Select all
>>>> edit("file.py")
Also I haven't come across a "NEW" command in Python to forget everything and start again. Although I suppose logging out and back in is easy enough.
It would be "easily" possible to create a new Python environment with the required commands built in to it, all the hooks are there. You would need to use an existing editor such as nano, (just because writing screen-based editors is not trivial,) but that's easy. It could be an interesting project for you and/or your nephew.
rurwin wrote:I suspect you will not find an editor that you can use from inside Python. You could do something likebut that would be horrible. You could build a few such utility functions and import them automatically, but they would still be function calls. So all your "commands" would look like
- Code: Select all
import os
os.system("nano file.py")
- Code: Select all
>>>> edit("file.py")
Also I haven't come across a "NEW" command in Python to forget everything and start again. Although I suppose logging out and back in is easy enough.
It would be "easily" possible to create a new Python environment with the required commands built in to it, all the hooks are there. You would need to use an existing editor such as nano, (just because writing screen-based editors is not trivial,) but that's easy. It could be an interesting project for you and/or your nephew.
Thanks. I only dabble in python and this seemed like such an obviously good idea that I was hoping this was already done! Another possibility is to use a python IDE as the shell. Is there such an easy to use python IDE?
Though I am more likely to create this in Scheme! It wouldn't be too hard to add an (ed) function that pops open an editor and upon closing loads the new or edited file. Or even (ed foo) -- if the function foo exists, the editor starts up with its code or else gives you a brand new template for a function. I think most Logo systems had a similar feature.
My nephew is more likely to write simple games in python and/or use gpio.
- Posts: 255
- Joined: Sun Sep 25, 2011 1:25 am
How about booting the RPi to X and starting few terminals (FE. python, and file editor and bash) automatically:
viewtopic.php?f=5&t=5225
And then you just specify the software you want to start at login in to the .xinitrc file in the users home directory.
viewtopic.php?f=5&t=5225
And then you just specify the software you want to start at login in to the .xinitrc file in the users home directory.
- Posts: 9
- Joined: Tue Jul 03, 2012 3:50 pm
Have a look at [IPython][http://ipython.org], it's awesome!
Start it with ipython --profile=pysh to make it look more like the normal system shell if you like.
You can start system commands directly from the prompt.
Start it with ipython --profile=pysh to make it look more like the normal system shell if you like.
You can start system commands directly from the prompt.
- Posts: 1
- Joined: Tue Jul 10, 2012 5:34 am
Vindolin wrote:Have a look at [IPython][http://ipython.org], it's awesome!
Start it with ipython --profile=pysh to make it look more like the normal system shell if you like.
You can start system commands directly from the prompt.
iPython looks quite promising. Thanks.
- Posts: 255
- Joined: Sun Sep 25, 2011 1:25 am
I like iPython. There's a few dependencies that need installing, but it went smoothly on this old Linux Mint box where I had to install everything from source-code tar-ball because the versions in the package manager were so old.
I especially like IPython Notebook. Very nice:

To make changes to a block of code just move the cursor back, make the edit and hit "play", the output appears and the cursor moves to the next block. The only thing to remember is that you have to play a function definition. (Which makes sense if your brain works that way.)
I especially like IPython Notebook. Very nice:

To make changes to a block of code just move the cursor back, make the edit and hit "play", the output appears and the cursor moves to the next block. The only thing to remember is that you have to play a function definition. (Which makes sense if your brain works that way.)