This file is indexed.

/usr/share/doc/pyxplot/html/sect0053.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
<!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: Modules and classes</title>

<link href="sect0054.html" title="File handles" rel="next" />
<link href="sect0052.html" title="Dates" 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="sect0052.html" title="Dates"><img alt="Previous: Dates" 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="sect0054.html" title="File handles"><img alt="Next: File handles" 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">Modules and classes</b>
</span>
</span>
<hr />
</div>

<div><h1 id="a0000000054">6.8 Modules and classes</h1>
<p>Modules provide a convenient way to group functions and variables together. Pyxplot’s default functions are grouped into modules such as <tt class="tt">os</tt> and <tt class="tt">random</tt>. New modules can be created by calling the <tt class="tt">module</tt> object, which is a synonym for <tt class="tt">types.module</tt>. Once created, a module is like a dictionary, except that its elements can be accessed both as <tt class="tt">module[item]</tt> and more commonly as <tt class="tt">module.item</tt>. For example: </p><p> <tt class="ttfamily">pyxplot&gt; <b class="bfseries">myFuncs = module()</b></tt><br /><tt class="ttfamily">pyxplot&gt; <b class="bfseries">myFuncs.squared(x) = x**2</b></tt><br /><tt class="ttfamily">pyxplot&gt; <b class="bfseries">myFuncs.cubed(x) = x**3</b></tt><br /><tt class="ttfamily">pyxplot&gt; <b class="bfseries">print myFuncs</b></tt><br /><tt class="ttfamily">module {</tt><br /><tt class="ttfamily">  cubed         : cubed(x)=x**3</tt><br /><tt class="ttfamily">  squared       : squared(x)=x**2</tt><br /><tt class="ttfamily"> }</tt><br /><tt class="ttfamily">pyxplot&gt; <b class="bfseries">print myFuncs.squared(4)</b></tt><br /><tt class="ttfamily">16</tt><br /><tt class="ttfamily">pyxplot&gt; <b class="bfseries">print myFuncs[’cubed’](2)</b></tt><br /><tt class="ttfamily">8</tt>   </p><p>Modules can also serve as class prototypes. If a module is called like a function, the return value is an <i class="it">instance</i> of the module: </p><p> <tt class="ttfamily">pyxplot&gt; <b class="bfseries">oldMan = module()</b></tt><br /><tt class="ttfamily">pyxplot&gt; <b class="bfseries">oldMan.info() = "Barefoot on the ice, <img src="images/img-0038.png" alt="$\backslash $" style="vertical-align:-5px; 
                                     width:7px; 
                                     height:18px" class="math gen" />n<img src="images/img-0038.png" alt="$\backslash $" style="vertical-align:-5px; 
                                     width:7px; 
                                     height:18px" class="math gen" /></b></tt><br /><tt class="ttfamily">.......&gt; <b class="bfseries">he staggers back and forth"</b></tt><br /><tt class="ttfamily">pyxplot&gt; <b class="bfseries">hurdyGurdyMan = oldMan()</b></tt><br /><tt class="ttfamily">pyxplot&gt; <b class="bfseries">hurdyGurdyMan.moreInfo() = "With numb fingers <img src="images/img-0038.png" alt="$\backslash $" style="vertical-align:-5px; 
                                     width:7px; 
                                     height:18px" class="math gen" />n<img src="images/img-0038.png" alt="$\backslash $" style="vertical-align:-5px; 
                                     width:7px; 
                                     height:18px" class="math gen" /></b></tt><br /><tt class="ttfamily">.......&gt; <b class="bfseries">he plays the best he can."</b></tt><br /><tt class="ttfamily">pyxplot&gt; <b class="bfseries">print hurdyGurdyMan.moreInfo()</b></tt><br /><tt class="ttfamily">With numb fingers <img src="images/img-0038.png" alt="$\backslash $" style="vertical-align:-5px; 
                                     width:7px; 
                                     height:18px" class="math gen" />nhe plays the best he can.</tt><br /><tt class="ttfamily">pyxplot&gt; <b class="bfseries">print hurdyGurdyMan.info()</b></tt><br /><tt class="ttfamily">Barefoot on the ice, <img src="images/img-0038.png" alt="$\backslash $" style="vertical-align:-5px; 
                                     width:7px; 
                                     height:18px" class="math gen" />nhe staggers back and forth</tt>   </p><p>The module <i class="it">instance</i> inherits all of the functions and variables of its parent object, but may also contain its own additional functions and variables, some of which may supersede those in the parent object if they have the same name. When functions or subroutines of a module instance are called, the special variable <tt class="tt">self</tt> is defined to equal the module instance object. This allows the function to store private data in the module instance, or to call other methods on the instance. </p><p> <tt class="ttfamily">pyxplot&gt; <b class="bfseries">animal = module()</b></tt><br /><tt class="ttfamily">pyxplot&gt; <b class="bfseries">animal.info() = "I am a %s."%self.type</b></tt><br /><tt class="ttfamily">pyxplot&gt; <b class="bfseries">animal.moreInfo() = "My name is %s."%self.name</b></tt><br /><tt class="ttfamily">pyxplot&gt; <b class="bfseries">cat = animal()</b></tt><br /><tt class="ttfamily">pyxplot&gt; <b class="bfseries">cat.type = "cat"</b></tt><br /><tt class="ttfamily">pyxplot&gt; <b class="bfseries">subroutine cat.poke() { print "miaox!" ; }</b></tt><br /><tt class="ttfamily">pyxplot&gt; <b class="bfseries">cat.moreInfo() = "My name is %s."%self.name</b></tt><br /><tt class="ttfamily">pyxplot&gt; <b class="bfseries">tiddles = cat()</b></tt><br /><tt class="ttfamily">pyxplot&gt; <b class="bfseries">tiddles.name = "tiddles"</b></tt><br /><tt class="ttfamily">pyxplot&gt; <b class="bfseries">print tiddles.info()</b></tt><br /><tt class="ttfamily">I am a cat.</tt><br /><tt class="ttfamily">pyxplot&gt; <b class="bfseries">print tiddles.moreInfo()</b></tt><br /><tt class="ttfamily">My name is tiddles.</tt><br /><tt class="ttfamily">pyxplot&gt; <b class="bfseries">call tiddles.poke()</b></tt><br /><tt class="ttfamily">miaox!</tt>   </p><p>As this example demonstrates, it is also possible to hierarchically instantiate modules: <tt class="tt">tiddles</tt> is an instance of <tt class="tt">cat</tt>, which is itself an instance of <tt class="tt">animal</tt>. </p></div>





<div class="navigation">
<table cellspacing="2" cellpadding="0" width="100%">
<tr>
<td><a href="sect0052.html" title="Dates"><img alt="Previous: Dates" 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="sect0054.html" title="File handles"><img alt="Next: File handles" 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>