Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76182
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Subject | Re: newbee |
| Date | 2014-08-13 11:57 +0200 |
| Organization | None |
| References | <CABhGeYW+Na5uhQ6Bdm31Vy2JU6JG_us3LHnz+a41WDCHyFUvrQ@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.12916.1407923891.18130.python-list@python.org> (permalink) |
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.
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
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
csiph-web