Learn Languages 2018 というイベントで、最近のPythonについて発表してきました。 (一昨年まではLightweight LanguageでLLイベントだったのが、去年からLearn Languagesイベントになったらしい!) Python update in 2018 #ll2018jp from cocodrips www.slideshare.net せっかくなのでポイントだけでも書き起こして見ようと思います。 ここ1~2年で便利になった機能 1. The pathlib module (PEP 428) pathlibはファイルパスに関するモジュールで3.4で導入されました。 ただ、build-inのopenやos.pathモジュールがpathlib.Pathオブジェクトを受け入れられるようになったのがPython3.6(PEP519)となっています。 3.
めちゃくちゃ長いですが 変数や属性に代入されるオブジェクトの型名を書く という、ただそれだけの話です。 # 1. はじめに 型ヒントの書き方については mypy のマニュアルにチートシートがありました。 わかる方は、直接こちらをご参照ください。 Type hints cheat sheet (Python 3) - mypy (opens new window) また型ヒントをいつ使うのか、と言った 「使い分け」 、型ヒントが登場した 「背景」 については、 以下の記事にまとめました。本記事の後編にあたります。 動的言語と静的言語ってなに? この記事では主に 「書き方」 と 「使い方」 について、書いていきます。 # 1.1. 型ヒント 変数に代入される型の名前です。 正確には違います。引用先の用語集をご参照ください。
TL; DR こいつを使うと、Annotation を追加していない部分に自動的に適用してくれます。 github.com もう少し詳しく 詳しい使い方はリポジトリを見ていただくとして、要はこの実装に対して実行すると、 gist.github.com こういう風になります。 gist.github.com 残念ながらこのエントリを書いている本日現在では python3 形式での変換には対応していないようですが、README の TODO に Python 3 code generation. と書いてあるのでそのうち対応されるんではないでしょうか。 ちなみに手動で書き換えるとこういう風になるんだと思います。 gist.github.com pytest と組み合わせるとさらに便利 pyannotate は実際に実行してみた結果を収集しながら型情報を適用するための JSON ファイルを生成
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く