Python

From Neural Wiki

Jump to: navigation, search
Python

“Strange women lying in ponds distributing swords is no basis for a system of government!” - Monty Python and the search for the Holy Grail (1975)
93 Articles May 24, 2013

[edit] Python

 "Your mother was a hamster and your father smelt of elderberries!"
"Your mother was a hamster and your father smelt of elderberries!"

From the Official python website

Python is a dynamic object-oriented programming language that can be used for many kinds of software development. It offers strong support for integration with other languages and tools, comes with extensive standard libraries, and can be learned in a few days. Many Python programmers report substantial productivity gains and feel the language encourages the development of higher quality, more maintainable code.

Python runs on Windows, Linux/Unix, Mac OS X, OS/2, Amiga, Palm Handhelds, and Nokia mobile phones. Python has also been ported to the Java and .NET virtual machines.

Because of its more general data types Python is applicable to a much larger problem domain than Awk or even Perl, yet many things are at least as easy in Python as in those languages.


By the way, the language is named after the BBC show ``Monty Python's Flying Circus and has nothing to do with nasty reptiles. Making references to Monty Python skits in documentation is not only allowed, it is encouraged!


[edit] Python Accessories

[edit] Installing Python in Windows Vista

Guide to installing Python in Windows Vista and making it work. Fortunately this is pretty simple to do, but unlike installing it in Windows XP, you will need to do a few things to make it work from the command prompt.

[edit] Using Python to control external devices

Using a module called PyVISA, Python can control external devices through GPIB, RS232 or USB interfaces. Check out my work interfacing a Tektronix TDS684b using a GPIB connection. GPIB and Python

[edit] Python Cookbook

The cookbook is full of ideas for implementing python code

[edit] Wrapping Fortran in Python

F2PY is a Python module that allows you to run Fortran code using Python. This can be extremely handy, since there are some processes where Fortran is much faster. Now you can use the versatility of Python and the speed of Fortran to have best of both worlds.

[edit] Accessing data with python

Loading data with python

[edit] Data Acquisition

For NIDAQmx

For PMD USB-1208FS

[edit] References

Article about Python for scientific computing

Nice reference with examples for python functions

In depth Python tutorial

[edit] Python Projects

Mikes Python Help

google and nasa both use python

[edit] Python Add ons

Matplotlib. This program really sets Python apart from Fortran because it allows you to create graphics within python. Before I was acquainted with Python, I would generate data in Fortran and graph the results using either GNUplot or Excel. Matplotlib is better and faster. It is based on the the graphics commands found in Matlab. Mikes Matplotlib help

[edit] Python related stuff

to save the program output to a file called out.txt

python program.py > out.txt

From a helpful Python 2.3 quick reference [1]

Invocation Options
   python[w] [-dEhiOQStuUvVWxX?] [-c command| scriptFile | - ] [args]
       (pythonw does not open a terminal/console; python does) 

Invocation Options Option Effect

-d Output parser debugging information (also PYTHONDEBUG=x)

-E Ignore environment variables (such as PYTHONPATH)

-h Print a help message and exit (formerly -?)

-i Inspect interactively after running script (also PYTHONINSPECT=x) and force prompts, even if stdin appears not to be a terminal.

-O Optimize generated bytecode (also PYTHONOPTIMIZE=x). Asserts are suppressed.

-OO Remove doc-strings in addition to the -O optimizations.

-Q arg Division options: -Qold (default), -Qwarn, -Qwarnall, -Qnew

-S Don't perform import site on initialization.

-t Issue warnings about inconsistent tab usage (-tt: issue errors).

-u Unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x).

-U Force Python to interpret all string literals as Unicode literals.

-v Verbose (trace import statements) (also PYTHONVERBOSE=x).

-V Print the Python version number and exit.

-W arg Warning control (arg is action:message:category:module:lineno)

-x Skip first line of source, allowing use of non-unix Forms of #!cmd

-X Disable class based built-in exceptions (for backward compatibility management of exceptions)

-c command Specify the command to execute (see next section). This terminates the option list (following options are passed as arguments to the command).

scriptFile The name of a python file (.py) to execute. Read from stdin.

- Program read from stdin (default; interactive mode if a tty).

args Passed to script or command (in sys.argv[1:])

 	If no scriptFile or command, Python enters interactive mode.

Personal tools
Cool project