You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: slides_sources/source/session05.rst
+30-10Lines changed: 30 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -87,6 +87,30 @@ What if you want a case-insensitive count?
87
87
In [3]: s.lower().count('t')
88
88
Out[3]: 3
89
89
90
+
set.update()
91
+
------------
92
+
93
+
If you want to add a bunch of stuff to a set, you can use update:
94
+
95
+
.. code-block:: ipython
96
+
97
+
In [1]: s = set()
98
+
99
+
In [2]: s.update
100
+
Out[2]: <function set.update>
101
+
102
+
In [3]: s.update(['this', 'that'])
103
+
104
+
In [4]: s
105
+
Out[4]: {'that', 'this'}
106
+
107
+
In [5]: s.update(['this', 'thatthing'])
108
+
109
+
In [6]: s
110
+
Out[6]: {'that', 'thatthing', 'this'}
111
+
112
+
**NOTE:** It's VERY often the case that when you find yourself writing a trivial loop -- there is a way to do it with a built in method!
113
+
90
114
91
115
92
116
Sorting stuff in dictionaries:
@@ -280,6 +304,8 @@ But some of you are not sure how to start.
280
304
281
305
So let's start from the beginning...
282
306
307
+
NOTE: think about set vs list.
308
+
283
309
(demo)
284
310
285
311
Lightning Talks
@@ -727,7 +753,6 @@ Catch up!
727
753
Material to review before next week:
728
754
====================================
729
755
730
-
<<<<<<<HEAD
731
756
**Unit Testing:**
732
757
733
758
* Dive into Python: chapter 9:
@@ -736,19 +761,14 @@ Material to review before next week:
736
761
NOTE: you will find that most introductions to unit testing with Python use the builtin ``unitest`` module. However, it is a bit heavyweight, and requires some knowledge of OOP-- classes, etc. So we'll be using pytest in this class: http://doc.pytest.org/en/latest/. But the principles of testing are the same.
0 commit comments