SEESenv/web/html/ch5func.html
changeset 25 ed38dd9bdb50
parent 24 10074d1357ff
child 27 cb14131583c6
equal deleted inserted replaced
24:10074d1357ff 25:ed38dd9bdb50
    25      </b>
    25      </b>
    26     </p>
    26     </p>
    27     <dl>
    27     <dl>
    28      <dt>
    28      <dt>
    29       <span class="article">
    29       <span class="article">
    30        <a href="#id2813580">
    30        <a href="#id2621478">
    31         Functional Approach
    31         Functional Approach
    32        </a>
    32        </a>
    33       </span>
    33       </span>
    34      </dt>
    34      </dt>
    35      <dd>
    35      <dd>
    36       <dl>
    36       <dl>
    37        <dt>
    37        <dt>
    38         <span class="section">
    38         <span class="section">
    39          <a href="#id2864618">
    39          <a href="#id2672516">
    40           1. Function scope
    40           1. Function scope
    41          </a>
    41          </a>
    42         </span>
    42         </span>
    43        </dt>
    43        </dt>
    44        <dt>
    44        <dt>
    45         <span class="section">
    45         <span class="section">
    46          <a href="#id2864676">
    46          <a href="#id2672574">
    47           2. Default Arguments
    47           2. Default Arguments
    48          </a>
    48          </a>
    49         </span>
    49         </span>
    50        </dt>
    50        </dt>
    51        <dt>
    51        <dt>
    52         <span class="section">
    52         <span class="section">
    53          <a href="#id2864716">
    53          <a href="#id2672613">
    54           3. Keyword Arguments
    54           3. Keyword Arguments
    55          </a>
    55          </a>
    56         </span>
    56         </span>
    57        </dt>
    57        </dt>
    58        <dt>
    58        <dt>
    59         <span class="section">
    59         <span class="section">
    60          <a href="#id2864832">
    60          <a href="#id2672729">
    61           4. Parameter Packing and Unpacking
    61           4. Parameter Packing and Unpacking
    62          </a>
    62          </a>
    63         </span>
    63         </span>
    64        </dt>
    64        </dt>
    65        <dt>
    65        <dt>
    66         <span class="section">
    66         <span class="section">
    67          <a href="#id2864932">
    67          <a href="#id2672829">
    68           5. Nested Functions and Scopes
    68           5. Nested Functions and Scopes
    69          </a>
    69          </a>
    70         </span>
    70         </span>
    71        </dt>
    71        </dt>
    72        <dt>
    72        <dt>
    73         <span class="section">
    73         <span class="section">
    74          <a href="#id2864984">
    74          <a href="#id2672879">
    75           6. map, reduce and filter functions
    75           6. map, reduce and filter functions
    76          </a>
    76          </a>
    77         </span>
    77         </span>
    78        </dt>
    78        </dt>
    79        <dd>
    79        <dd>
    80         <dl>
    80         <dl>
    81          <dt>
    81          <dt>
    82           <span class="section">
    82           <span class="section">
    83            <a href="#id2865174">
    83            <a href="#id2673069">
    84             6.1. List Comprehensions
    84             6.1. List Comprehensions
    85            </a>
    85            </a>
    86           </span>
    86           </span>
    87          </dt>
    87          </dt>
    88         </dl>
    88         </dl>
    94    <div class="article" title="Functional Approach">
    94    <div class="article" title="Functional Approach">
    95     <div class="titlepage">
    95     <div class="titlepage">
    96      <div>
    96      <div>
    97       <div>
    97       <div>
    98        <h2 class="title">
    98        <h2 class="title">
    99         <a name="id2813580">
    99         <a name="id2621478">
   100         </a>
   100         </a>
   101         Functional Approach
   101         Functional Approach
   102        </h2>
   102        </h2>
   103       </div>
   103       </div>
   104      </div>
   104      </div>
   111       </b>
   111       </b>
   112      </p>
   112      </p>
   113      <dl>
   113      <dl>
   114       <dt>
   114       <dt>
   115        <span class="section">
   115        <span class="section">
   116         <a href="#id2864618">
   116         <a href="#id2672516">
   117          1. Function scope
   117          1. Function scope
   118         </a>
   118         </a>
   119        </span>
   119        </span>
   120       </dt>
   120       </dt>
   121       <dt>
   121       <dt>
   122        <span class="section">
   122        <span class="section">
   123         <a href="#id2864676">
   123         <a href="#id2672574">
   124          2. Default Arguments
   124          2. Default Arguments
   125         </a>
   125         </a>
   126        </span>
   126        </span>
   127       </dt>
   127       </dt>
   128       <dt>
   128       <dt>
   129        <span class="section">
   129        <span class="section">
   130         <a href="#id2864716">
   130         <a href="#id2672613">
   131          3. Keyword Arguments
   131          3. Keyword Arguments
   132         </a>
   132         </a>
   133        </span>
   133        </span>
   134       </dt>
   134       </dt>
   135       <dt>
   135       <dt>
   136        <span class="section">
   136        <span class="section">
   137         <a href="#id2864832">
   137         <a href="#id2672729">
   138          4. Parameter Packing and Unpacking
   138          4. Parameter Packing and Unpacking
   139         </a>
   139         </a>
   140        </span>
   140        </span>
   141       </dt>
   141       </dt>
   142       <dt>
   142       <dt>
   143        <span class="section">
   143        <span class="section">
   144         <a href="#id2864932">
   144         <a href="#id2672829">
   145          5. Nested Functions and Scopes
   145          5. Nested Functions and Scopes
   146         </a>
   146         </a>
   147        </span>
   147        </span>
   148       </dt>
   148       </dt>
   149       <dt>
   149       <dt>
   150        <span class="section">
   150        <span class="section">
   151         <a href="#id2864984">
   151         <a href="#id2672879">
   152          6. map, reduce and filter functions
   152          6. map, reduce and filter functions
   153         </a>
   153         </a>
   154        </span>
   154        </span>
   155       </dt>
   155       </dt>
   156       <dd>
   156       <dd>
   157        <dl>
   157        <dl>
   158         <dt>
   158         <dt>
   159          <span class="section">
   159          <span class="section">
   160           <a href="#id2865174">
   160           <a href="#id2673069">
   161            6.1. List Comprehensions
   161            6.1. List Comprehensions
   162           </a>
   162           </a>
   163          </span>
   163          </span>
   164         </dt>
   164         </dt>
   165        </dl>
   165        </dl>
   328     <div class="section" title="1.Function scope">
   328     <div class="section" title="1.Function scope">
   329      <div class="titlepage">
   329      <div class="titlepage">
   330       <div>
   330       <div>
   331        <div>
   331        <div>
   332         <h2 class="title" style="clear: both">
   332         <h2 class="title" style="clear: both">
   333          <a name="id2864618">
   333          <a name="id2672516">
   334          </a>
   334          </a>
   335          1.Function scope
   335          1.Function scope
   336         </h2>
   336         </h2>
   337        </div>
   337        </div>
   338       </div>
   338       </div>
   404     <div class="section" title="2.Default Arguments">
   404     <div class="section" title="2.Default Arguments">
   405      <div class="titlepage">
   405      <div class="titlepage">
   406       <div>
   406       <div>
   407        <div>
   407        <div>
   408         <h2 class="title" style="clear: both">
   408         <h2 class="title" style="clear: both">
   409          <a name="id2864676">
   409          <a name="id2672574">
   410          </a>
   410          </a>
   411          2.Default Arguments
   411          2.Default Arguments
   412         </h2>
   412         </h2>
   413        </div>
   413        </div>
   414       </div>
   414       </div>
   452     <div class="section" title="3.Keyword Arguments">
   452     <div class="section" title="3.Keyword Arguments">
   453      <div class="titlepage">
   453      <div class="titlepage">
   454       <div>
   454       <div>
   455        <div>
   455        <div>
   456         <h2 class="title" style="clear: both">
   456         <h2 class="title" style="clear: both">
   457          <a name="id2864716">
   457          <a name="id2672613">
   458          </a>
   458          </a>
   459          3.Keyword Arguments
   459          3.Keyword Arguments
   460         </h2>
   460         </h2>
   461        </div>
   461        </div>
   462       </div>
   462       </div>
   590     <div class="section" title="4.Parameter Packing and Unpacking">
   590     <div class="section" title="4.Parameter Packing and Unpacking">
   591      <div class="titlepage">
   591      <div class="titlepage">
   592       <div>
   592       <div>
   593        <div>
   593        <div>
   594         <h2 class="title" style="clear: both">
   594         <h2 class="title" style="clear: both">
   595          <a name="id2864832">
   595          <a name="id2672729">
   596          </a>
   596          </a>
   597          4.Parameter Packing and Unpacking
   597          4.Parameter Packing and Unpacking
   598         </h2>
   598         </h2>
   599        </div>
   599        </div>
   600       </div>
   600       </div>
   632   }
   632   }
   633   """
   633   """
   634 
   634 
   635   print "Title: %s" % (title)
   635   print "Title: %s" % (title)
   636   print "Full name: %(first)s %(middle)s %(last)s" % name
   636   print "Full name: %(first)s %(middle)s %(last)s" % name
   637   print "Age: %d\nEmail-ID: %s" % args
   637   print "Age: %d nEmail-ID: %s" % args
   638      </pre>
   638      </pre>
   639      <p id="ch5func_16">
   639      <p id="ch5func_16">
   640       The above function can be called as. Note, the order of keyword parameters can
   640       The above function can be called as. Note, the order of keyword parameters can
   641 be interchanged:
   641 be interchanged:
   642      </p>
   642      </p>
   679      </p>
   679      </p>
   680      <pre class="programlisting">
   680      <pre class="programlisting">
   681       def print_report(title, age, email, first, middle, last):
   681       def print_report(title, age, email, first, middle, last):
   682   print "Title: %s" % (title)
   682   print "Title: %s" % (title)
   683   print "Full name: %s %s %s" % (first, middle, last)
   683   print "Full name: %s %s %s" % (first, middle, last)
   684   print "Age: %d\nEmail-ID: %s" % (age, email)
   684   print "Age: %d nEmail-ID: %s" % (age, email)
   685 
   685 
   686 &gt;&gt;&gt; args = (29, 'johny@example.com')
   686 &gt;&gt;&gt; args = (29, 'johny@example.com')
   687 &gt;&gt;&gt; name = {
   687 &gt;&gt;&gt; name = {
   688         'first': 'Johny',
   688         'first': 'Johny',
   689         'middle': 'Charles',
   689         'middle': 'Charles',
   699     <div class="section" title="5.Nested Functions and Scopes">
   699     <div class="section" title="5.Nested Functions and Scopes">
   700      <div class="titlepage">
   700      <div class="titlepage">
   701       <div>
   701       <div>
   702        <div>
   702        <div>
   703         <h2 class="title" style="clear: both">
   703         <h2 class="title" style="clear: both">
   704          <a name="id2864932">
   704          <a name="id2672829">
   705          </a>
   705          </a>
   706          5.Nested Functions and Scopes
   706          5.Nested Functions and Scopes
   707         </h2>
   707         </h2>
   708        </div>
   708        </div>
   709       </div>
   709       </div>
   725        </em>
   725        </em>
   726       </span>
   726       </span>
   727       in
   727       in
   728 Python you are suggested to read:
   728 Python you are suggested to read:
   729      </p>
   729      </p>
   730      <span style="color: red">
   730      <div class="reference">
   731       &lt;line_block&gt;
   731       <div class="titlepage">
   732       <span style="color: red">
   732        <hr />
   733        &lt;line&gt;
   733       </div>
   734        <div class="reference">
   734       http://avinashv.net/2008/04/python-decorators-syntactic-sugar/
   735         <div class="titlepage">
   735      </div>
   736          <hr />
   736      <div class="reference">
   737         </div>
   737       <div class="titlepage">
   738         http://avinashv.net/2008/04/python-decorators-syntactic-sugar/
   738        <hr />
   739        </div>
   739       </div>
   740        &lt;/line&gt;
   740       http://personalpages.tds.net/~kent37/kk/00001.html
   741       </span>
   741      </div>
   742       <span style="color: red">
       
   743        &lt;line&gt;
       
   744        <div class="reference">
       
   745         <div class="titlepage">
       
   746          <hr />
       
   747         </div>
       
   748         http://personalpages.tds.net/~kent37/kk/00001.html
       
   749        </div>
       
   750        &lt;/line&gt;
       
   751       </span>
       
   752       &lt;/line_block&gt;
       
   753      </span>
       
   754      <p id="ch5func_19">
   742      <p id="ch5func_19">
   755       However, the following is an example for nested functions in Python:
   743       However, the following is an example for nested functions in Python:
   756      </p>
   744      </p>
   757      <pre class="programlisting">
   745      <pre class="programlisting">
   758       def outer():
   746       def outer():
   768     <div class="section" title="6.map, reduce and filter functions">
   756     <div class="section" title="6.map, reduce and filter functions">
   769      <div class="titlepage">
   757      <div class="titlepage">
   770       <div>
   758       <div>
   771        <div>
   759        <div>
   772         <h2 class="title" style="clear: both">
   760         <h2 class="title" style="clear: both">
   773          <a name="id2864984">
   761          <a name="id2672879">
   774          </a>
   762          </a>
   775          6.map, reduce and filter functions
   763          6.map, reduce and filter functions
   776         </h2>
   764         </h2>
   777        </div>
   765        </div>
   778       </div>
   766       </div>
  1018      <div class="section" title="6.1.List Comprehensions">
  1006      <div class="section" title="6.1.List Comprehensions">
  1019       <div class="titlepage">
  1007       <div class="titlepage">
  1020        <div>
  1008        <div>
  1021         <div>
  1009         <div>
  1022          <h3 class="title">
  1010          <h3 class="title">
  1023           <a name="id2865174">
  1011           <a name="id2673069">
  1024           </a>
  1012           </a>
  1025           6.1.List Comprehensions
  1013           6.1.List Comprehensions
  1026          </h3>
  1014          </h3>
  1027         </div>
  1015         </div>
  1028        </div>
  1016        </div>