これはPython Advent Calendar 2016 7日目の記事です. アドベントカレンダーの日程を勘違いしてしまっていたので,社内向けに作ったPython資料を使いまわすことでお茶を濁します。。。 Pythonの値渡しと参照渡しについてまとめてみます. Pythonでは,変数や関数に値を渡す場合すべて参照渡しで渡されています.例えば挙動だけ見れば値渡しに見えるint型でも,値が変更されるまでは元の値と同一のオブジェクトを参照しています. 例を見てみましょう. >>> def foo(a): ... print(a, id(a)) ... a += 1 ... print(a, id(a)) ... >>> b = 0 >>> print(b, id(b)) 0 4297514880 # 'b' 用の領域が確保されている >>> foo(b) 0 4297514880 # ここま
I have never considered Python to be heavily influenced by functional languages, no matter what people say or think. I was much more familiar with imperative languages such as C and Algol 68 and although I had made functions first-class objects, I didn't view Python as a functional programming language. However, earlier on, it was clear that users wanted to do much more with lists and functions. A
Many functional programming articles teach abstract functional techniques. That is, composition, pipelining, higher order functions. This one is different. It shows examples of imperative, unfunctional code that people write every day and translates these examples to a functional style. The first section of the article takes short, data transforming loops and translates them into functional maps a
In this series we take an in-depth look at transducers. Transducers - a portmanteau of "transform reducers" - are a new functional programming concept introduced into the Clojure programming language. Although transducers are actually pretty straightforward in retrospect, wrapping your brain around them, especially if you're not already a competent Clojureist, can be challenging. In this series, w
What are exceptions? Judging by their name it is an entity representing some exceptional situation that happens inside your program. You might be wondering how do exceptions are an anti-pattern and how does this relate to typing at all? Well, let’s find out! Problems with exceptions First, we have to prove that exceptions have drawbacks. Well, it is usually hard to find “issues” in things you use
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く