/usr/share/doc/pyxplot/html/sect0041.html is in pyxplot-doc 0.9.2-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta name="generator" content="plasTeX" />
<meta content="text/html; charset=utf-8" http-equiv="content-type" />
<title>PyXPlot Users' Guide: Lists</title>
<link href="sect0042.html" title="Using lists as stacks" rel="next" />
<link href="sect0040.html" title="Regular expressions" rel="prev" />
<link href="chap-progDataTypes.html" title="Programming: Pyxplot’s data types" rel="up" />
<link rel="stylesheet" href="styles/styles.css" />
</head>
<body>
<div class="navigation">
<table cellspacing="2" cellpadding="0" width="100%">
<tr>
<td><a href="sect0040.html" title="Regular expressions"><img alt="Previous: Regular expressions" border="0" src="icons/previous.gif" width="32" height="32" /></a></td>
<td><a href="chap-progDataTypes.html" title="Programming: Pyxplot’s data types"><img alt="Up: Programming: Pyxplot’s data types" border="0" src="icons/up.gif" width="32" height="32" /></a></td>
<td><a href="sect0042.html" title="Using lists as stacks"><img alt="Next: Using lists as stacks" border="0" src="icons/next.gif" width="32" height="32" /></a></td>
<td class="navtitle" align="center">PyXPlot Users' Guide</td>
<td><a href="index.html" title="Table of Contents"><img border="0" alt="" src="icons/contents.gif" width="32" height="32" /></a></td>
<td><a href="sect0288.html" title="Index"><img border="0" alt="" src="icons/index.gif" width="32" height="32" /></a></td>
<td><img border="0" alt="" src="icons/blank.gif" width="32" height="32" /></td>
</tr>
</table>
</div>
<div class="breadcrumbs">
<span>
<span>
<a href="index.html">PyXPlot Users' Guide</a> <b>:</b>
</span>
</span><span>
<span>
<a href="sect0001.html">Introduction to PyXPlot</a> <b>:</b>
</span>
</span><span>
<span>
<a href="chap-progDataTypes.html">Programming: Pyxplot’s data types</a> <b>:</b>
</span>
</span><span>
<span>
<b class="current">Lists</b>
</span>
</span>
<hr />
</div>
<div><h1 id="a0000000042">6.3 Lists</h1>
<p>List objects hold ordered sequences of other Pyxplot objects, which may include lists and dictionaries to create hierarchical data structures. They are created by enclosing a comma-separated list of objects by square brackets. </p><p>For example: </p><pre>
a = [10,colors.green,"bottles"]
</pre><p>Once created, more items can be added to a list using its <tt class="tt">append(item)</tt> and <tt class="tt">insert(n,item)</tt> methods, where the latter inserts an item at position <img src="images/img-0025.png" alt="$n$" style="vertical-align:0px;
width:11px;
height:8px" class="math gen" />: </p><p> <tt class="ttfamily">pyxplot> <b class="bfseries">theFive = ["Cui","Mussorgsky"]</b></tt><br /><tt class="ttfamily">pyxplot> <b class="bfseries">theFive.append("Borodin")</b></tt><br /><tt class="ttfamily">["Cui", "Mussorgsky", "Borodin"]</tt><br /><tt class="ttfamily">pyxplot> <b class="bfseries">theFive.insert(0,"Balakirev")</b></tt><br /><tt class="ttfamily">["Balakirev", "Cui", "Mussorgsky", "Borodin"]</tt><br /><tt class="ttfamily">pyxplot> <b class="bfseries">theFive.insert(-2,"Rimsky-Korsakov")</b></tt><br /><tt class="ttfamily">["Balakirev", "Cui", "Mussorgsky", "Rimsky-Korsakov", "Borodin"]</tt> </p><p>A complete list of the methods available on lists (itself a list of strings) can be found by calling the method <tt class="tt">[].methods()</tt>; they are also listed in Section <a></a>. As with string methods, documentation of list methods is returned if the method object is printed: </p><p> <tt class="ttfamily">pyxplot> <b class="bfseries">print [].append</b></tt><br /><tt class="ttfamily">append(x) appends the object x to a list.</tt><br /><tt class="ttfamily">pyxplot> <b class="bfseries">print [].insert</b></tt><br /><tt class="ttfamily">insert(n,x) inserts the object x into a list at position n.</tt> </p><p>Most methods that operate on lists, for example, append, extend and sort operations, return the list as their output. Unless this is stored in a variable, Pyxplot prints this return value to the terminal. In some cases this is useful: in the example above, it allowed us to see how the list was changing when we called its <tt class="tt">append()</tt> and <tt class="tt">insert()</tt> methods. Often, however, this terminal spam is unwanted. The <tt class="tt">call</tt> command<a name="a0000000612" id="a0000000612"></a> allows methods to be called without printing their output, which is discarded: </p><p> <tt class="ttfamily">pyxplot> <b class="bfseries">a = ["William I"]</b></tt><br /><tt class="ttfamily">pyxplot> <b class="bfseries">call a.extend(["William II","Henry I"])</b></tt><br /><tt class="ttfamily">pyxplot> <b class="bfseries">call a.insert(0,"Edgar II")</b></tt><br /><tt class="ttfamily">pyxplot> <b class="bfseries">call a.insert(0,"Edward the Confessor")</b></tt><br /><tt class="ttfamily">pyxplot> <b class="bfseries">print a</b></tt><br /><tt class="ttfamily">["Edward the Confessor", "Edgar II", "William I", "William II", "Henry I"]</tt> </p></div>
<div class="contents section-contents"><!--<strong>Subsections</strong>-->
<ul>
<li><a href="sect0042.html">6.3.1 Using lists as stacks</a>
</li><li><a href="sect0043.html">6.3.2 Using lists as buffers</a>
</li><li><a href="sect0044.html">6.3.3 Sorting lists</a>
</li><li><a href="sect0045.html">6.3.4 Iterating over lists</a>
</li><li><a href="sect0046.html">6.3.5 Calling functions with lists of arguments</a>
</li><li><a href="sec-listfilter.html">6.3.6 List mapping and filtering</a>
</li><li><a href="sect0047.html">6.3.7 Vectors versus lists</a>
</li>
</ul>
</div>
<div class="navigation">
<table cellspacing="2" cellpadding="0" width="100%">
<tr>
<td><a href="sect0040.html" title="Regular expressions"><img alt="Previous: Regular expressions" border="0" src="icons/previous.gif" width="32" height="32" /></a></td>
<td><a href="chap-progDataTypes.html" title="Programming: Pyxplot’s data types"><img alt="Up: Programming: Pyxplot’s data types" border="0" src="icons/up.gif" width="32" height="32" /></a></td>
<td><a href="sect0042.html" title="Using lists as stacks"><img alt="Next: Using lists as stacks" border="0" src="icons/next.gif" width="32" height="32" /></a></td>
<td class="navtitle" align="center">PyXPlot Users' Guide</td>
<td><a href="index.html" title="Table of Contents"><img border="0" alt="" src="icons/contents.gif" width="32" height="32" /></a></td>
<td><a href="sect0288.html" title="Index"><img border="0" alt="" src="icons/index.gif" width="32" height="32" /></a></td>
<td><img border="0" alt="" src="icons/blank.gif" width="32" height="32" /></td>
</tr>
</table>
</div>
<script language="javascript" src="icons/imgadjust.js" type="text/javascript"></script>
</body>
</html>
|