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> |
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> |
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 >>> args = (29, 'johny@example.com') |
686 >>> args = (29, 'johny@example.com') |
687 >>> name = { |
687 >>> name = { |
688 'first': 'Johny', |
688 'first': 'Johny', |
689 'middle': 'Charles', |
689 'middle': 'Charles', |
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 <line_block> |
731 <div class="titlepage"> |
732 <span style="color: red"> |
732 <hr /> |
733 <line> |
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 </line> |
740 http://personalpages.tds.net/~kent37/kk/00001.html |
741 </span> |
741 </div> |
742 <span style="color: red"> |
|
743 <line> |
|
744 <div class="reference"> |
|
745 <div class="titlepage"> |
|
746 <hr /> |
|
747 </div> |
|
748 http://personalpages.tds.net/~kent37/kk/00001.html |
|
749 </div> |
|
750 </line> |
|
751 </span> |
|
752 </line_block> |
|
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> |