Skip to Content
Python in a Nutshell
book

Python in a Nutshell

by Alex Martelli
March 2003
Intermediate to advanced
656 pages
39h 30m
English
O'Reilly Media, Inc.
Content preview from Python in a Nutshell

Name

array2string

Synopsis

array2string(a,max_line_width=None,precision=None,
             suppress_small=None,separator=' ',
            array_output=False)

Returns a string representation s of array a, showing elements within brackets, separated by string separator. The last dimension is horizontal, the penultimate one vertical, and further dimensions are denoted by bracket nesting. If array_output is true, s starts with 'array(' and ends with ')‘. s ends with ",'X')" instead if X, which is a’s type code, is not Float, Complex, or Int, which lets you later use eval( s ) if separator is ',‘.

Lines longer than max_line_width (by default, 77) are broken up. precision determines how many digits are used per element (by default, 8). If suppress_small is true, very small numbers are shown as 0. You can change these defaults by binding attributes of module sys named output_line_width, float_output_precision, and float_output_suppress_small.

str( a ) is like array2string( a ). repr( a ) is like array2string( a ,separator=', ',array_output=True).

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python in a Nutshell, 3rd Edition

Python in a Nutshell, 3rd Edition

Alex Martelli, Anna Ravenscroft, Steve Holden
Python in a Nutshell, 4th Edition

Python in a Nutshell, 4th Edition

Alex Martelli, Anna Martelli Ravenscroft, Steve Holden, Paul McGuire
Data Wrangling with Python

Data Wrangling with Python

Jacqueline Kazil, Katharine Jarmul

Publisher Resources

ISBN: 0596001886Supplemental ContentCatalog PageErrata