background preloader

Python

Facebook Twitter

Python page Richard Gruet @ free.fr. Calling an external command in Python. 23.2. shlex — Simple lexical analysis. New in version 1.5.2. Source code: Lib/shlex.py The shlex class makes it easy to write lexical analyzers for simple syntaxes resembling that of the Unix shell. This will often be useful for writing minilanguages, (for example, in run control files for Python applications) or for parsing quoted strings. Prior to Python 2.7.3, this module did not support Unicode input. The shlex module defines the following functions: shlex.split(s[, comments[, posix]]) Split the string s using shell-like syntax.

New in version 2.3. Changed in version 2.6: Added the posix parameter. Note Since the split() function instantiates a shlex instance, passing None for s will read the string to split from standard input. The shlex module defines the following class: class shlex.shlex([instream[, infile[, posix]]]) A shlex instance or subclass instance is a lexical analyzer object. See also Module ConfigParser Parser for configuration files similar to the Windows .ini files. 23.2.1. shlex Objects shlex.get_token() shlex.wordchars. Printing - how to print to stderr in python. Array API — NumPy v1.7.dev-470c857 Manual. NumPy stores an internal table of Python callable objects that are used to implement arithmetic operations for arrays as well as certain array calculation methods.

This function allows the user to replace any or all of these Python objects with their own versions. The keys of the dictionary, dict, are the named functions to replace and the paired value is the Python callable object to use. Care should be taken that the function used to replace an internal array operation does not itself call back to that internal array operation (unless you have designed the function to handle that), or an unchecked infinite recursion can result (possibly causing program crash). The key names that represent operations that can be replaced are: These functions are included here because they are used at least once in the array object’s methods.

The function returns -1 (without setting a Python Error) if one of the objects being assigned is not callable. Ndimage.filters.gaussian_filter1d — SciPy v0.11.dev Reference Guide.