| | 27 | |
| | 28 | === Quick Start Guide (for IDL users) === |
| | 29 | |
| | 30 | '''How to open the door:''' |
| | 31 | |
| | 32 | Once you have Python installed, you can run an interactive session by invoking "python" at the command line.[br] |
| | 33 | (This is equivalent to writing "IDL" on the command line.)[br] |
| | 34 | % python |
| | 35 | |
| | 36 | >>> |
| | 37 | |
| | 38 | You will very often need to activate different packages for your python session. Numpy is one that you will probably need often. |
| | 39 | >>> import numpy |
| | 40 | |
| | 41 | Now each time you need to use something from numpy, you will invoke that package: |
| | 42 | >>> x = numpy.array([1,2,3,4]) |
| | 43 | |
| | 44 | You can also give the package a nickname for use within your session, for example: |
| | 45 | >>> import numpy as np |
| | 46 | |
| | 47 | >>> x = np.array([1,2,3,4]) |
| | 48 | |
| | 49 | When you want to quit python, press Ctrl+D or: |
| | 50 | >>> exit() |
| | 51 | |
| | 52 | Now let's say you want to run the equivalent of a "batch" file. In IDL you would do the following: |
| | 53 | % IDL |
| | 54 | |
| | 55 | IDL> @my_batchfile.batch |
| | 56 | |
| | 57 | In python, you would create a file containing everything you would run from the command line (including "import numpy" etc etc). Then from the command line, you can enter: |
| | 58 | % python -i my_pyfile.py |
| | 59 | |
| | 60 | >>> |
| | 61 | |
| | 62 | The code will compile and open an "interactive" session. You can access and play with all the variables you created in my_pyfile.py. |
| | 63 | |
| | 64 | |
| | 65 | This is how I do it! Please add your own tips and tricks. (Added by [mailto:lia@astro.columbia.edu]) |