Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76182 > unrolled thread
| Started by | Peter Otten <__peter__@web.de> |
|---|---|
| First post | 2014-08-13 11:57 +0200 |
| Last post | 2014-08-13 10:59 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: newbee Peter Otten <__peter__@web.de> - 2014-08-13 11:57 +0200
Re: newbee Duncan Booth <duncan.booth@invalid.invalid> - 2014-08-13 10:59 +0000
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Date | 2014-08-13 11:57 +0200 |
| Subject | Re: newbee |
| Message-ID | <mailman.12916.1407923891.18130.python-list@python.org> |
Frank Scafidi wrote: > I just acquired a Raspberry Pi and want to program in Python. I was a PL/1 > programmer back in the 60's & 70's and Python is similar. I am struggling > with some very fundamental things that I am not finding in the > documentation. Can someone help me with the basics like how do I save a > program I've written, reload it in Python, list the program once it's > loaded? How do I edit a program? Are these command line functions? You can use any text editor to write a python script. A simple editor which might be present ont the Pi is called "nano". It shows the hotkeys to store the text and quit the editor, and thus should be self-explanatory: $ nano helloworld.py Once you have written your simple script you can look at it with the "cat" command: $ cat helloworld.py #!/usr/bin/env python print "Hello world" Invoke it with: $ python helloworld.py Hello world You can also make your script "executable" which means that the first line controls which program is used to run it: $ chmod +x helloworld.py $ ./helloworld.py Hello world $ If the script is in a directory listed in the PATH environment variable you can omit the path (the "./" in the above example): $ mv helloworld.py ~/bin $ helloworld.py Hello world PS: I ran the above demo on a Linux system, but not on the Raspberry Pi, so if something doesn't work as shown above it's probably due to the difference between the two systems.
[toc] | [next] | [standalone]
| From | Duncan Booth <duncan.booth@invalid.invalid> |
|---|---|
| Date | 2014-08-13 10:59 +0000 |
| Message-ID | <XnsA3887A0021B64duncanbooth@127.0.0.1> |
| In reply to | #76182 |
Peter Otten <__peter__@web.de> wrote: > Frank Scafidi wrote: > >> I just acquired a Raspberry Pi and want to program in Python. I was a >> PL/1 programmer back in the 60's & 70's and Python is similar. I am >> struggling with some very fundamental things that I am not finding in >> the documentation. Can someone help me with the basics like how do I >> save a program I've written, reload it in Python, list the program >> once it's loaded? How do I edit a program? Are these command line >> functions? > > You can use any text editor to write a python script. A simple editor > which might be present ont the Pi is called "nano". It shows the > hotkeys to store the text and quit the editor, and thus should be > self-explanatory: > > $ nano helloworld.py > > Once you have written your simple script you can look at it with the > "cat" command: > > $ cat helloworld.py > #!/usr/bin/env python > print "Hello world" > > Invoke it with: > > $ python helloworld.py > Hello world > > You can also make your script "executable" which means that the first > line controls which program is used to run it: > > $ chmod +x helloworld.py > $ ./helloworld.py > Hello world > $ > > If the script is in a directory listed in the PATH environment > variable you can omit the path (the "./" in the above example): > > $ mv helloworld.py ~/bin > $ helloworld.py > Hello world > > PS: I ran the above demo on a Linux system, but not on the Raspberry > Pi, so if something doesn't work as shown above it's probably due to > the difference between the two systems. > All of the above should work just fine on a Pi. The only thing I thing you could have added is that you also have the option of using Idle to edit and run Python programs. If you are running Raspian on your Pi then you will find an icon to run Idle sitting on the initial desktop. There's an introduction to using Idle on the Raspberry Pi at http://www.raspberrypi.org/documentation/usage/python/ -- Duncan Booth
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web