Python tutorial

De Bajas Temperaturas
(Redirigido desde «Python BT»)
Ir a la navegaciónIr a la búsqueda

A page about Python with useful links and chunks of code for the Low Temperatures Laboratory/CNEA.

Links

Python.org
Python is a widely used general-purpose, high-level programming language. Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than would be possible in languages such as C. The language provides constructs intended to enable clear programs on both a small and large scale. Python supports multiple programming paradigms, including object-oriented, imperative and functional programming or procedural styles. It features a dynamic type system and automatic memory management and has a large and comprehensive standard library.
SciPyStack
SciPy (pronounced “Sigh Pie”) is a Python-based ecosystem of open-source software for mathematics, science, and engineering.
Installing SciPyStack
FYI
NumPy
NumPy: array processing for numbers, strings, records, and objects. NumPy is a general-purpose array-processing package designed to efficiently manipulate large multi-dimensional arrays of arbitrary records without sacrificing too much speed for small multi-dimensional arrays. NumPy is built on the Numeric code base and adds features introduced by numarray as well as an extended C-API and the ability to create arrays of arbitrary type which also makes NumPy suitable for interfacing with general-purpose data-base applications.
GTK+ for Python
PyGTK lets you to easily create programs with a graphical user interface using the Python programming language. The underlying GTK+ library provides all kind of visual elements and utilities for it and, if needed, you can develop full featured applications for the GNOME Desktop. PyGTK applications are truly multiplatform and they're able to run, unmodified, on Linux, Windows, MacOS X and other platforms.
Linux, Windows, MacOS X
PyDAQmx National Instruments
This package allows users to use data acquisition hardware from National Instruments with Python. It provides an interface between the NIDAQmx driver and Python.
The package works on Windows and Linux.
Python(x,y)
A free distribution including the SciPy stack, based around the Spyder IDE.
Python(x,y) is a scientific-oriented Python Distribution based on Qt and Spyder. Its purpose is to help scientific programmers used to interpreted languages (such as MATLAB or IDL) or compiled languages (C/C++ or Fortran) to switch to Python. C/C++ or Fortran programmers should appreciate to reuse their code "as is" by wrapping it so it can be called directly from Python scripts.
Windows only.
Spyder
Spyder (previously known as Pydee) is a powerful interactive development environment for the Python language with advanced editing, interactive testing, debugging and introspection features.
Run on all platforms.
Anaconda
Anaconda is a completely free Python distribution (including for commercial use and redistribution). It includes over 195 of the most popular Python packages for science, math, engineering, data analysis. Completely free enterprise-ready Python distribution for large-scale data processing, predictive analytics, and scientific computing.
Cross platform, supports Linux, Windows and Mac.
WinPython
WinPython is a free open-source portable distribution of the Python programming language for Windows XP/7/8, designed for scientists, supporting both 32bit and 64bit versions of Python 2 and Python 3.
Windows only.
Enthought Canopy
The free and commercial versions include the core SciPy stack packages.
Scientific and Analytic Python Deployment with Integrated Analysis Environment. Enthought Canopy is a comprehensive Python analysis environment that provides easy installation of the core scientific analytic and scientific Python packages, creating a robust platform you can explore, develop, and visualize on. In addition to its pre-built, tested Python distribution, Enthought Canopy has valuable tools for iterative data analysis, visualization and application development.
Supports Linux, Windows and Mac.
Python for scientific computing: Where to start
This page is a guide for how to install Python and start using it for scientific computing.

Programming

String to bytes conversion
Previous versions of Python did a lot of the string to bytes conversion for you. Now days, in Python3+ you need to handle the data-type conversion yourself depending on your output/input.
Cookbook: Data Acquisition with NIDAQmx
These are quick examples of using ctypes and numpy to do data acquisition and playback using National Instrument's NI-DAQmx library. This library allows access to their wide range of data acquisition devices.
Python Modules
Python has a way to put definitions in a file and use them in a script or in an interactive instance of the interpreter. Such a file is called a module. A module is a file containing Python definitions and statements...
Python 2to3
How to convert python2 to python3
PyDAQmx usage
PyDAQmx usage, basic examples and notes about the library.
PyGTK/PyObj + Windows
I have an application which depends on PyGTK, PyGobject, and PyCairo that I built to work on Linux. I want to port it over to windows, but when I execute import gobject I get this...

Python usage of graphics interface: python2 -> pygtk python3 -> pygobj

NI6353

X Series Physical Channels
X Series Physical Channels

Code

#Dirs
import os
os.getcwd()
os.chdir("C:\\Path\Etc") 


#python2to3
python 2to3 -w .