Changes between Version 15 and Version 16 of Wisdom/Python


Ignore:
Timestamp:
04/13/12 17:09:33 (14 years ago)
Author:
lia@…
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Wisdom/Python

    v15 v16  
    2525
    2626- [mailto:adrn@astro.columbia.edu Adrian]
     27
     28=== Quick Start Guide (for IDL users) ===
     29
     30'''How to open the door:'''
     31
     32Once 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
     38You 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
     41Now each time you need to use something from numpy, you will invoke that package:
     42 >>> x = numpy.array([1,2,3,4])
     43
     44You 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
     49When you want to quit python, press Ctrl+D or:
     50 >>> exit()
     51
     52Now 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
     57In 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
     62The 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
     65This is how I do it!  Please add your own tips and tricks.  (Added by [mailto:lia@astro.columbia.edu])