-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.html
849 lines (615 loc) · 39.7 KB
/
index.html
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
<!DOCTYPE html>
<html lang="en" prefix="og: http://ogp.me/ns# fb: https://www.facebook.com/2008/fbml">
<head>
<title>The Digital Cat</title>
<!-- Using the latest rendering mode for IE -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Liquid tags START -->
<!-- Liquid tags START -->
<link href="http://blog.thedigitalcatonline.com/images/TheDigitalCat_favicon_32.png" rel="icon">
<link rel="canonical" href="http://blog.thedigitalcatonline.com">
<meta name="author" content="Leonardo Giordani" />
<!-- Open Graph tags -->
<meta property="og:site_name" content="The Digital Cat" />
<meta property="og:type" content="website"/>
<meta property="og:title" content="The Digital Cat"/>
<meta property="og:url" content="http://blog.thedigitalcatonline.com"/>
<meta property="og:description" content="The Digital Cat"/>
<meta property="og:image"
content="http://blog.thedigitalcatonline.com/images/TheDigitalCat_logo_200.jpg"/>
<!-- Bootstrap and Bootswatch CSS START -->
<link href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.5/spacelab/bootstrap.min.css" rel="stylesheet">
<!-- Bootstrap and Bootswatch CSS END -->
<!-- Font Awesome CSS START -->
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet">
<!-- Font Awesome CSS END -->
<!-- Pygments CSS START -->
<link href="http://blog.thedigitalcatonline.com/theme/css/pygments/monokai.css" rel="stylesheet">
<!-- Pygments CSS END -->
<!-- Custom CSS START -->
<!-- Custom CSS END -->
<!-- Docutils CSS START -->
<!-- Docutils CSS START -->
<link rel="stylesheet" href="http://blog.thedigitalcatonline.com/theme/css/style.css" type="text/css"/>
<link href="http://blog.thedigitalcatonline.com/atom.xml" type="application/atom+xml" rel="alternate"
title="The Digital Cat ATOM Feed"/>
<!-- Google Analytics Universal -->
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-74364524-1', 'auto');
ga('send', 'pageview');
</script>
<!-- End Google Analytics Universal Code -->
</head>
<body>
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="http://blog.thedigitalcatonline.com/" class="navbar-brand">
<i class="fa fa-paw fa-lg"></i> <span class="icon-label">The Digital Cat</span>
</a>
</div>
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav">
<li><a href="http://blog.thedigitalcatonline.com/pages/about.html">
About
</a></li>
<li >
<a href="http://blog.thedigitalcatonline.com/category/programming/">Programming</a>
</li>
<li >
<a href="http://blog.thedigitalcatonline.com/category/projects/">Projects</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="http://blog.thedigitalcatonline.com/archives"><i class="fa fa-th-list"></i><span class="icon-label">Archives</span></a></li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
</div> <!-- /.navbar -->
<!-- Banner START -->
<div id="banner" style="background-image:url(http://blog.thedigitalcatonline.com/images/TheDigitalCat_favicon_32.png);">
<aside>
<div class="container">
<div class="copy">
<h1>The Digital Cat</h1>
<p class="intro">Adventures of a curious cat in the land of programming</p>
</div>
</div>
</aside>
</div><!-- Banner END -->
<div class="container">
<div class="row">
<div class="col-sm-9">
<article>
<h2><a href="http://blog.thedigitalcatonline.com/blog/2016/09/27/python-mocks-a-gentle-introduction-part-2/">Python Mocks: a gentle introduction - Part 2</a></h2>
<div class="well well-sm">
<footer class="post-info">
<span class="label label-default">Date</span>
<span class="published">
<time datetime="2016-09-27T09:00:00+00:00"> 27/09/2016</time>
</span>
<span class="label label-default">Tags</span>
<a href="http://blog.thedigitalcatonline.com/categories/decorators/">decorators</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/oop/">OOP</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/python/">Python</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/python2/">Python2</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/python3/">Python3</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/tdd/">TDD</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/testing/">testing</a>
</footer><!-- /.post-info --> </div>
<div class="summary">
<p>In the <a href="/blog/2016/03/06/python-mocks-a-gentle-introduction-part-1">first post</a> I introduced you to Python mocks, objects that can imitate other objects and work as placeholders, replacing external systems during unit testing. I described the basic behaviour of mock objects, the <code>return_value</code> and <code>side_effect</code> attributes, and the <code>assert_called_with()</code> method.</p>
<p>In this post I will briefly review the remaining <code>assert_*</code> methods and some interesting attributes that allow to check the calls received by the mock object. Then I will introduce and exemplify patching, which is a very important topic in testing.</p>
<h2>Other assertions and attributes</h2>
<p>The <a href="https://docs.python.org/dev/library/unittest.mock.html">official documentation</a> of the mock library lists many other assertion, namely <code>assert_called_once_with()</code>, <code>assert_any_call()</code>, <code>assert_has_calls()</code>, <code>assert_not_called()</code>. If you
<a href="http://blog.thedigitalcatonline.com/blog/2016/09/27/python-mocks-a-gentle-introduction-part-2/"><strong>... more</strong></a>
</div>
</article>
<hr/>
<article>
<h2><a href="http://blog.thedigitalcatonline.com/blog/2016/05/31/punch-update-your-version-while-having-a-drink/">Punch - Update your version while having a drink</a></h2>
<div class="well well-sm">
<footer class="post-info">
<span class="label label-default">Date</span>
<span class="published">
<time datetime="2016-05-31T16:00:00+01:00"> 31/05/2016</time>
</span>
<span class="label label-default">Tags</span>
<a href="http://blog.thedigitalcatonline.com/categories/git/">Git</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/python/">Python</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/python2/">Python2</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/python3/">Python3</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/versioning/">versioning</a>
</footer><!-- /.post-info --> </div>
<div class="summary">
<p>So you completed your wonderful new project, all your test are successful (you <a href="/categories/tdd/">test</a> code, don't you?) and you just want to ship the new version and call it a day. Well, you just have to go and change the version number in your install script and save. Oh, right, you also have to open a feature branch, so that you may record the version update in your Git history. Well, easily done. Damn! You forgot to change the version number in the README.md file...</p>
<p>Managing the version number of a project is not easy. Not only you need to think about the versioning scheme and what part of the version to increase (see <a href="/blog/2013/03/20/versioning-an-underrated-discipline/">this post</a> for some tips on this matter), but you also need to remember in which files you put the actual version number, and, depending on your workflow, to correctly manage the version control system commits.</p>
<p><strong>Punch</strong> is a small tool that aims to simplify the latter parts, that is
<a href="http://blog.thedigitalcatonline.com/blog/2016/05/31/punch-update-your-version-while-having-a-drink/"><strong>... more</strong></a>
</div>
</article>
<hr/>
<article>
<h2><a href="http://blog.thedigitalcatonline.com/blog/2016/04/03/abstract-base-classes-in-python/">Abstract Base Classes in Python</a></h2>
<div class="well well-sm">
<footer class="post-info">
<span class="label label-default">Date</span>
<span class="published">
<time datetime="2016-04-03T11:00:00+01:00"> 03/04/2016</time>
</span>
<span class="label label-default">Tags</span>
<a href="http://blog.thedigitalcatonline.com/categories/decorators/">decorators</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/metaclasses/">metaclasses</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/metaprogramming/">metaprogramming</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/notebook/">Notebook</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/oop/">OOP</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/python/">Python</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/python2/">Python2</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/python3/">Python3</a>
</footer><!-- /.post-info --> </div>
<div class="summary">
<p>With the introduction of Abstract Base Classes, Python once again shows its nature of a very innovative and flexible language. It is interesting to see how such a remarkable feature has been introduced into the language by a pure Python module. This demonstrates that Python is built in a way that is very open to changes, thanks to its foundations in pure polymorphism based on delegation.</p>
<p>Many Python programmers overlooked Abstract Base Classes and the classes in the <code>collections</code> module, which are one of the simplest and useful applications of the concept. Sure enough, this is not a feature that you will use every day or that will change the way you are programming in Python. But neither is it something you shall discard before understanding what it brings into the language, and what sort of problems it can solve for you.</p>
<h1>Level 1</h1>
<h2>EAFP</h2>
<p>Python is a dynamically-typed object-oriented language strongly based on delegation, so its approach to problems is intrinsically
<a href="http://blog.thedigitalcatonline.com/blog/2016/04/03/abstract-base-classes-in-python/"><strong>... more</strong></a>
</div>
</article>
<hr/>
<article>
<h2><a href="http://blog.thedigitalcatonline.com/blog/2016/03/06/python-mocks-a-gentle-introduction-part-1/">Python Mocks: a gentle introduction - Part 1</a></h2>
<div class="well well-sm">
<footer class="post-info">
<span class="label label-default">Date</span>
<span class="published">
<time datetime="2016-03-06T18:00:00+01:00"> 06/03/2016</time>
</span>
<span class="label label-default">Tags</span>
<a href="http://blog.thedigitalcatonline.com/categories/decorators/">decorators</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/oop/">OOP</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/python/">Python</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/python2/">Python2</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/python3/">Python3</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/tdd/">TDD</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/testing/">testing</a>
</footer><!-- /.post-info --> </div>
<div class="summary">
<p>As already stressed in the two introductory posts on TDD (you can find them <a href="/categories/tdd/">here</a>) testing requires to write some code that uses the functions and objects you are going to develop. This means that you need to isolate a given (external) function that is part of your public API and demonstrate that it works with standard inputs and in edge cases.</p>
<p>For example, if you are going to develop an object that stores percentages (such as for example poll results), you should test the following conditions: the class can store a standard percentage such as 42%, the class shall give an error if you try to store a negative percentage, the class shall give an error if you store a percentage greater than 100%.</p>
<p>Tests shall be <em>idempotent</em> and <em>isolated</em>. Idempotent in mathematics and computer science identifies a process that can be run multiple times without changing the status of the system. Isolated means that a test shall not change its behaviour depending on
<a href="http://blog.thedigitalcatonline.com/blog/2016/03/06/python-mocks-a-gentle-introduction-part-1/"><strong>... more</strong></a>
</div>
</article>
<hr/>
<article>
<h2><a href="http://blog.thedigitalcatonline.com/blog/2015/09/22/clojure-sequential-data-types-for-python-programmers/">Clojure sequential data types for Python programmers</a></h2>
<div class="well well-sm">
<footer class="post-info">
<span class="label label-default">Date</span>
<span class="published">
<time datetime="2015-09-22T19:00:00+01:00"> 22/09/2015</time>
</span>
<span class="label label-default">Tags</span>
<a href="http://blog.thedigitalcatonline.com/categories/functional-programming/">functional programming</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/python/">Python</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/python2/">Python2</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/python3/">Python3</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/clojure/">Clojure</a>
</footer><!-- /.post-info --> </div>
<div class="summary">
<p>I have been working with Python for more than fifteen years and I developed very big systems with this language, learning to know and love both its power and its weaknesses, admiring its gorgeous object-oriented system and exploring some of its darkest corners.</p>
<p>Despite being so committed to this language (both for personal choices and for business reasons) I never stopped learning new languages, trying to get a clear picture of new (or old) paradigms, to explore new solutions to old problems and in general to get my mind open.</p>
<p>Unfortunately introducing a new language in your business is always very risky, expensive and many times not a decision of yours only. You are writing software that other may have to maintain, so either you evangelize your team and persuade other to join you or you will be forced to stay with the languages shared by them. This is not bad in itself, but sometimes it is a big obstacle for the adoption of a new language.</p>
<p>One of the languages I fell in love (but
<a href="http://blog.thedigitalcatonline.com/blog/2015/09/22/clojure-sequential-data-types-for-python-programmers/"><strong>... more</strong></a>
</div>
</article>
<hr/>
<article>
<h2><a href="http://blog.thedigitalcatonline.com/blog/2015/09/10/python-oop-tdd-example-part2/">A simple example of Python OOP development (with TDD) - Part 2</a></h2>
<div class="well well-sm">
<footer class="post-info">
<span class="label label-default">Date</span>
<span class="published">
<time datetime="2015-09-10T20:00:00+01:00"> 10/09/2015</time>
</span>
<span class="label label-default">Tags</span>
<a href="http://blog.thedigitalcatonline.com/categories/oop/">OOP</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/python/">Python</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/python3/">Python3</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/tdd/">TDD</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/testing/">testing</a>
</footer><!-- /.post-info --> </div>
<div class="summary">
<p>In <a href="/blog/2015/05/13/python-oop-tdd-example-part1/">the first part</a> of this small series I introduced you to TDD with Python by means of the powerful <code>py.test</code> package. We developed together a simple library which provides a <code>Binary</code> class that is a bit more useful than the default binary representation that Python provides with the <code>bin()</code> builtin function.</p>
<p>In this part I'll go on with the development of the library, discussing the implementation of a binary number with a fixed size, which is a very interesting and useful matter, being the foundation of the computer we are working with. Fixed-size binaries may also represent negative numbers with the two's complement technique, and this will be an important point to test.</p>
<p>You may happen to dislike some decisions about the interface or the behaviour of the resulting class. Since this post is just a way to show you a concrete TDD session you are totally free to change the tests and to come up with a
<a href="http://blog.thedigitalcatonline.com/blog/2015/09/10/python-oop-tdd-example-part2/"><strong>... more</strong></a>
</div>
</article>
<hr/>
<article>
<h2><a href="http://blog.thedigitalcatonline.com/blog/2015/06/22/using-gitflow-with-github-a-simple-procedure/">Using gitflow with GitHub: a simple procedure</a></h2>
<div class="well well-sm">
<footer class="post-info">
<span class="label label-default">Date</span>
<span class="published">
<time datetime="2015-06-22T14:00:00+01:00"> 22/06/2015</time>
</span>
<span class="label label-default">Tags</span>
<a href="http://blog.thedigitalcatonline.com/categories/git/">Git</a>
</footer><!-- /.post-info --> </div>
<div class="summary">
<p>Git is a very powerful version control system and much of its power comes from its very simple basic structures. Git is mostly a manager of blob trees and even the most complex operations are basically tree operations.</p>
<p>The power of Git brings also a great flexibility, which means that Git doesn't dictate a specific workflow, leaving the programmer or the team to come up with a reasonable procedure.</p>
<h2>Workflows</h2>
<p>Two Git workflows are very widespread, for different reasons. The first is the GitHub model and the second is the gitflow one.</p>
<p>The GitHub model is widely used, because nowadays GitHub is the most used code management and collaboration website for open source projects. GitHub makes use of a workflow based on Pull Requests, and you can find some useful resources about it in the relative section at the end of the post.</p>
<p>Gitflow was proposed by Vincent Driessen in 2010 and quickly become one of the most used workflows, due to the fact that it covers most of the common
<a href="http://blog.thedigitalcatonline.com/blog/2015/06/22/using-gitflow-with-github-a-simple-procedure/"><strong>... more</strong></a>
</div>
</article>
<hr/>
<article>
<h2><a href="http://blog.thedigitalcatonline.com/blog/2015/05/13/python-oop-tdd-example-part1/">A simple example of Python OOP development (with TDD) - Part 1</a></h2>
<div class="well well-sm">
<footer class="post-info">
<span class="label label-default">Date</span>
<span class="published">
<time datetime="2015-05-13T17:00:00+01:00"> 13/05/2015</time>
</span>
<span class="label label-default">Tags</span>
<a href="http://blog.thedigitalcatonline.com/categories/oop/">OOP</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/python/">Python</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/python3/">Python3</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/tdd/">TDD</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/testing/">testing</a>
</footer><!-- /.post-info --> </div>
<div class="summary">
<p>If you are eager to learn some Python and do not know how to start, this post may give you some hints. I will develop a very simple Python package from scratch, exemplifying some Object-oriented Programming (OOP) techniques and concepts, and using a Test-Driven Development (TDD) approach.</p>
<p>The package will provide some classes to deal with binary numbers (see the Rationale section), but remember that it is just a toy project. Nothing in this package has been designed with performance in mind: it wants to be as clear as possible.</p>
<h2>Rationale</h2>
<p>Binary numbers are rather easy to understand, even if becoming familiar with them requires some time. I expect you to have knowledge of the binary numeral system. If you need to review them just take a look at the <a href="http://en.wikipedia.org/wiki/Binary_number">Wikipedia entry</a> or one of the countless resources on Internet.</p>
<p>The package we are going to write will provide a class that represents binary numbers (<code>Binary</code>) and
<a href="http://blog.thedigitalcatonline.com/blog/2015/05/13/python-oop-tdd-example-part1/"><strong>... more</strong></a>
</div>
</article>
<hr/>
<article>
<h2><a href="http://blog.thedigitalcatonline.com/blog/2015/05/13/99-scala-problems-16-20/">99 Scala Problems 16-20</a></h2>
<div class="well well-sm">
<footer class="post-info">
<span class="label label-default">Date</span>
<span class="published">
<time datetime="2015-05-13T16:00:00+01:00"> 13/05/2015</time>
</span>
<span class="label label-default">Tags</span>
<a href="http://blog.thedigitalcatonline.com/categories/scala/">Scala</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/functional-programming/">functional programming</a>
</footer><!-- /.post-info --> </div>
<div class="summary">
<h1>Problem 16</h1>
<h2>The problem</h2>
<p><strong>P16</strong> (**) Drop every Nth element from a list.</p>
<p>Example:</p>
<div class="highlight"><pre><span></span><span class="n">scala</span><span class="o">></span> <span class="n">drop</span><span class="o">(</span><span class="mi">3</span><span class="o">,</span> <span class="nc">List</span><span class="o">(</span><span class=" -Symbol">'a</span><span class="o">,</span> <span class=" -Symbol">'b</span><span class="o">,</span> <span class=" -Symbol">'c</span><span class="o">,</span> <span class=" -Symbol">'d</span><span class="o">,</span> <span class=" -Symbol">'e</span><span class="o">,</span> <span class=" -Symbol">'f</span><span class="o">,</span> <span class=" -Symbol">'g</span><span class="o">,</span> <span class=" -Symbol">'h</span><span class="o">,</span> <span class=" -Symbol">'i</span><span class="o">,</span> <span class=" -Symbol">'j</span><span class="o">,</span> <span class="
<a href="http://blog.thedigitalcatonline.com/blog/2015/05/13/99-scala-problems-16-20/"><strong>... more</strong></a>
</div>
</article>
<hr/>
<article>
<h2><a href="http://blog.thedigitalcatonline.com/blog/2015/04/23/python-decorators-metaprogramming-with-style/">Python decorators: metaprogramming with style</a></h2>
<div class="well well-sm">
<footer class="post-info">
<span class="label label-default">Date</span>
<span class="published">
<time datetime="2015-04-23T13:00:00+01:00"> 23/04/2015</time>
</span>
<span class="label label-default">Tags</span>
<a href="http://blog.thedigitalcatonline.com/categories/decorators/">decorators</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/functional-programming/">functional programming</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/metaprogramming/">metaprogramming</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/oop/">OOP</a>
/
<a href="http://blog.thedigitalcatonline.com/categories/python/">Python</a>
</footer><!-- /.post-info --> </div>
<div class="summary">
<p>This post is the result of a lot of personal research on Python decorators, meta- and functional programming. I want however to thank Bruce Eckel and the people behind the open source book "Python 3 Patterns, Recipes and Idioms" for a lot of precious information on the subject. See the Resources section at the end of the post to check their work.</p>
<h2>Is Python functional?</h2>
<p>Well, no. Python is a strong object-oriented programming language and is not really going to mix OOP and functional like, for example, Scala (which is a very good language, by the way).</p>
<p>However, Python provides <em>some</em> features taken from functional programming. <a href="/blog/2013/03/25/python-generators-from-iterators-to-cooperative-multitasking">Generators and iterators</a> are one of them, and Python is not the only non pure functional programming language to have them in their toolbox.</p>
<p>Perhaps the most distinguishing feature of <a href="http://en.wikipedia.org/wiki/Functional_programming">functional
<a href="http://blog.thedigitalcatonline.com/blog/2015/04/23/python-decorators-metaprogramming-with-style/"><strong>... more</strong></a>
</div>
</article>
<hr/>
<ul class="pagination">
<li class="prev disabled"><a href="#">«</a></li>
<li class="active"><a href="http://blog.thedigitalcatonline.com/">1</a></li>
<li class=""><a href="http://blog.thedigitalcatonline.com/page/2/">2</a></li>
<li class=""><a href="http://blog.thedigitalcatonline.com/page/3/">3</a></li>
<li class=""><a href="http://blog.thedigitalcatonline.com/page/4/">4</a></li>
<li class=""><a href="http://blog.thedigitalcatonline.com/page/5/">5</a></li>
<li class=""><a href="http://blog.thedigitalcatonline.com/page/6/">6</a></li>
<li class="next"><a
href="http://blog.thedigitalcatonline.com/page/2/">»</a></li>
</ul>
</div>
<div class="col-sm-3" id="sidebar">
<aside>
<section class="well well-sm">
<ul class="list-group list-group-flush">
<li class="list-group-item"><h4><i class="fa fa-cloud fa-lg"></i><span class="icon-label">Social</span></h4>
<ul class="list-group" id="social">
<li class="list-group-item"><a href="https://twitter.com/thedigicat"><i class="fa fa-twitter-square fa-lg"></i> Twitter</a></li>
<li class="list-group-item"><a href="https://plus.google.com/u/0/111444750762335924049"><i class="fa fa-google-plus-square fa-lg"></i> Google+</a></li>
<li class="list-group-item"><a href="https://github.com/TheDigitalCatOnline"><i class="fa fa-github-square fa-lg"></i> GitHub</a></li>
</ul>
</li>
<li class="list-group-item"><h4><i class="fa fa-feed fa-lg"></i><span class="icon-label">Feeds</span></h4>
<ul class="list-group">
<li class="list-group-item"><a href="http://blog.thedigitalcatonline.com/atom.xml">The Digital Cat</a></li>
</ul>
</li>
<li class="list-group-item"><h4><i class="fa fa-calendar fa-lg"></i><span class="icon-label">Recent Posts</span></h4>
<ul class="list-group" id="recentposts">
<li class="list-group-item">
<a href="http://blog.thedigitalcatonline.com/blog/2016/09/27/python-mocks-a-gentle-introduction-part-2/">
Python Mocks: a gentle introduction - Part 2
</a>
</li>
<li class="list-group-item">
<a href="http://blog.thedigitalcatonline.com/blog/2016/05/31/punch-update-your-version-while-having-a-drink/">
Punch - Update your version while having a drink
</a>
</li>
<li class="list-group-item">
<a href="http://blog.thedigitalcatonline.com/blog/2016/04/03/abstract-base-classes-in-python/">
Abstract Base Classes in Python
</a>
</li>
<li class="list-group-item">
<a href="http://blog.thedigitalcatonline.com/blog/2016/03/06/python-mocks-a-gentle-introduction-part-1/">
Python Mocks: a gentle introduction - Part 1
</a>
</li>
</ul>
</li>
<li class="list-group-item"><a href="http://blog.thedigitalcatonline.com/"><h4><i class="fa fa-tags fa-lg"></i><span class="icon-label">Tags</span></h4></a>
<ul class="list-group list-inline tagcloud" id="tags-side">
<li class="list-group-item tag-4">
<a href="http://blog.thedigitalcatonline.com/categories/amqp/">
AMQP
</a>
</li>
<li class="list-group-item tag-2">
<a href="http://blog.thedigitalcatonline.com/categories/c/">
C
</a>
</li>
<li class="list-group-item tag-4">
<a href="http://blog.thedigitalcatonline.com/categories/clojure/">
Clojure
</a>
</li>
<li class="list-group-item tag-2">
<a href="http://blog.thedigitalcatonline.com/categories/concurrent-programming/">
concurrent programming
</a>
</li>
<li class="list-group-item tag-4">
<a href="http://blog.thedigitalcatonline.com/categories/cpp/">
C++
</a>
</li>
<li class="list-group-item tag-2">
<a href="http://blog.thedigitalcatonline.com/categories/decorators/">
decorators
</a>
</li>
<li class="list-group-item tag-3">
<a href="http://blog.thedigitalcatonline.com/categories/django/">
Django
</a>
</li>
<li class="list-group-item tag-3">
<a href="http://blog.thedigitalcatonline.com/categories/erlang/">
Erlang
</a>
</li>
<li class="list-group-item tag-1">
<a href="http://blog.thedigitalcatonline.com/categories/functional-programming/">
functional programming
</a>
</li>
<li class="list-group-item tag-3">
<a href="http://blog.thedigitalcatonline.com/categories/generators/">
generators
</a>
</li>
<li class="list-group-item tag-3">
<a href="http://blog.thedigitalcatonline.com/categories/git/">
Git
</a>
</li>
<li class="list-group-item tag-2">
<a href="http://blog.thedigitalcatonline.com/categories/metaclasses/">
metaclasses
</a>
</li>
<li class="list-group-item tag-2">
<a href="http://blog.thedigitalcatonline.com/categories/metaprogramming/">
metaprogramming
</a>
</li>
<li class="list-group-item tag-3">
<a href="http://blog.thedigitalcatonline.com/categories/notebook/">
Notebook
</a>
</li>
<li class="list-group-item tag-1">
<a href="http://blog.thedigitalcatonline.com/categories/oop/">
OOP
</a>
</li>
<li class="list-group-item tag-2">
<a href="http://blog.thedigitalcatonline.com/categories/operating-systems/">
operating systems
</a>
</li>
<li class="list-group-item tag-4">
<a href="http://blog.thedigitalcatonline.com/categories/pika/">
Pika
</a>
</li>
<li class="list-group-item tag-4">
<a href="http://blog.thedigitalcatonline.com/categories/postage/">
Postage
</a>
</li>
<li class="list-group-item tag-1">
<a href="http://blog.thedigitalcatonline.com/categories/python/">
Python
</a>
</li>
<li class="list-group-item tag-2">
<a href="http://blog.thedigitalcatonline.com/categories/python2/">
Python2
</a>
</li>
<li class="list-group-item tag-1">
<a href="http://blog.thedigitalcatonline.com/categories/python3/">
Python3
</a>
</li>
<li class="list-group-item tag-4">
<a href="http://blog.thedigitalcatonline.com/categories/qt/">
Qt
</a>
</li>
<li class="list-group-item tag-3">
<a href="http://blog.thedigitalcatonline.com/categories/rabbitmq/">
RabbitMQ
</a>
</li>
<li class="list-group-item tag-1">
<a href="http://blog.thedigitalcatonline.com/categories/scala/">
Scala
</a>
</li>
<li class="list-group-item tag-2">
<a href="http://blog.thedigitalcatonline.com/categories/tdd/">
TDD
</a>
</li>
<li class="list-group-item tag-2">
<a href="http://blog.thedigitalcatonline.com/categories/testing/">
testing
</a>
</li>
<li class="list-group-item tag-3">
<a href="http://blog.thedigitalcatonline.com/categories/versioning/">
versioning
</a>
</li>
</ul>
</li>
</ul>
</section>
</aside>
</div>
</div>
</div>
<footer>
<div class="container">
<hr>
<div class="row">
<div class="col-xs-10">© 2016 Leonardo Giordani
· Powered by <a href="https://github.com/lgiordani/laces3" target="_blank">laces3</a>,
<a href="http://docs.getpelican.com/" target="_blank">Pelican</a>,
<a href="http://getbootstrap.com" target="_blank">Bootstrap 3</a>
<p><small> <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="//i.creativecommons.org/l/by-sa/4.0/80x15.png" /></a>
Content
licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a>, except where indicated otherwise.
</small></p>
</div>
<div class="col-xs-2"><p class="pull-right"><i class="fa fa-arrow-up"></i> <a href="#">Back to top</a></p></div>
</div>
</div>
</footer>
<!-- JQuery JS START -->
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<!-- JQuery JS END -->
<!-- Bootstrap JS START -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<!-- Bootstrap JS END -->
<!-- Enable responsive features in IE8 with Respond.js (https://github.com/scottjehl/Respond) -->
<!-- Respond JS START -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<!-- Respond JS END -->
<!-- Begin Cookie Consent -->
<script>
window.cookieconsent_options = {
message: "This website uses cookies to ensure you get the best experience on our website.",
learnMore: "More info",
link: "http://cookielawinfo.com/about/",
theme: 'http://blog.thedigitalcatonline.com/theme/css/cookieconsent2/dark-top.css',
};
</script>
<script src="http://blog.thedigitalcatonline.com/theme/js/cookieconsent.min.js"></script>
<!-- End Cookie Consent -->
</body>
</html>