砲撃する自走砲(PzH2000自走榴弾砲)。自走砲は戦車によく似ていますが、戦車ではありません。*本編とは関係ありません。 こんにちは、エムスリー基盤開発チーム小本です。 Pythonのパッケージ管理周りでは、 「setup.pyでrequirements.txtを読み込むのが普通なんですよね?」 「pipenv があれば venv はオワコンなんですね?」 「pyenvは要らないんですよね!?」 「Pythonは歴史が古い分、Rubyなどに比べてカオス」 みたいな混乱をよく目にします。 実際、複数のツールがあって(一見)複雑です。また「なぜこうした状況にあるのか」がドキュメント化されているわけでもありません。 なので、私なりに整理してみることにしました。 ※「追伸」を追加しました。この記事では汎用プログラミング言語としてPythonを使うケース(Webアプリとか、CLIツールとか、ライブ
以前Pythonのパッケージ周りのベストプラクティスを理解する(2019年現在)を書きました。 この記事では「基本的には pipenvを使えばOK」と書きましたが、意図的に無視していた部分があります。 Poetryです。 Poetryは調べてみたのですが、各種日本語の記事(は一部の英語記事)はざっと読んだ限りでは、Poetryはどうにも了解できないことが多かったからです。そして、現時点ではPoetryよりPipenvの方が知名度が高そうだし、Pipenv自体は十分実用的なので「pipenvを使えばOK」としました。 とは言え、来年にはPoetryが天下をとっているかもしれません。そこで、そのうち書く記事の足がかりとして、あわよくば誰かが教えてくれたらいいなという虫のいい期待を込め、疑問点を列挙したいと思います。 Pipfile の使用はPEPで決まったものではない? それはどこまで問題でし
Python その2 Advent Calendar 2015の11日目の記事です。 はじめに 本記事では、pytestを使用した際に得たTipsを逆引き形式でまとめている。 また以下のリポジトリに本記事の内容を含んだサンプルプロジェクト(Python3.5.0/pytest2.8.4で確認)を置いているため、合わせて参考にして頂ければ。 https://github.com/FGtatsuro/pytest_sample pytestの特徴 pytestはその名のとおり、Pythonで書かれたテストライブラリ。同様のライブラリとしては、unittestやnoseがある。 上記2つのツールに精通していないため、それらと比較した形での評価は下せないが、個人的には以下のような点が特徴的だと感じた。 独自のassertメソッド(ex. assertEquals)を定義せずに、Python標準のa
pytestはPythonのテストフレームワークの一つ。 unittestなど他のフレームワークと比較して、テストに失敗した原因が分かりやすい。 この記事ではpytestの使い方に関して、公式のドキュメントを参考にメモする。 インストール pipなどを使用してインストールする。 基本的な使い方 基本的にはassertで望む結果を書く。 ここではtest_assert1.pyというテスト用のファイルを作成する。test_で始まる関数がテスト対象となる。ディスカバリーのルールに関してはこの記事の最後に明記する。 $ pytest test_assert1.py =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-3.
乗り換えるリポジトリ pyproject.toml の生成 依存パッケージのインストール コマンドラインツールとして実行できるようにする 乗り換えるリポジトリ GitHub - kk6/aeroplast: Transparent PNG conversion (Mainly for Twitter) twitterにアップロードしたPNGがJPGに強制変換されて見栄えが悪いという問題がある。それを回避するために画像の四隅どこかに1pxの透過ドットを打ち込むという方法がある。いちいちペイントソフトでそれを毎回やるのが面倒なのでコマンドラインで画像のPath渡したら変換してくれるコマンドラインツールを以前作った。こいつをPipenvで管理しているので、Poetryへの乗り換えを試してみる。 Poetry については数日中にもうちょっと突っ込んだ記事書きます。 pyproject.toml の
この記事は BeProud Advent Calender 2018 の20日目の記事です。そのためいつもよりボリュームたっぷり、文体も丁寧にお送りします。 adventar.org 本記事ではPoetryを使ってパッケージ開発→PyPIへ登録するまでの流れを紹介します。 github.com プロジェクト作成からPyPI登録までわずか30秒 Poetry について 基本的な使い方 Poetry と Pipenv Pipenvは確かに便利だけど Pipenv から Poetry に乗り換える Poetry と Pyenv PEP517 と PEP518 Poetryの各種設定 venvの作成先をプロジェクト内にしたい TestPyPIへアップロードできるようにする TestPyPIのユーザー名とパスワードを設定する ここまでの設定 プロジェクトを用意する 新規作成 標準的なレイアウト sr
テストを書くときに、外部の HTTP API を叩く処理が組み込まれている場合は、何かしらモックが必要です。 どう書くのがスマートなのか良くわからないので色々試してみる 準備するモノ python 2.7.x mock simplejson requests nose covarage テストのデファクト あまりまとまってるのがないので、まとめておきます。 テストランナーは nose または py.test nose はプラグインがステキ py.test はなにやら色々嬉しい事があるらしい モック/スタブは mock テストは unittest (unittest2) カヴァレッジは covarage ? これは良くわからず、基本 Jenkins に食べさせらるタイプで出力できればおk この辺が今のところデファクトでしょうか、ご意見お待ちしております。 mock patch を使うと綺麗に
The Exploit Database is maintained by OffSec, an information security training company that provides various Information Security Certifications as well as high end penetration testing services. The Exploit Database is a non-profit project that is provided as a public service by OffSec. The Exploit Database is a CVE compliant archive of public exploits and corresponding vulnerable software, develo
PEP 484 – Type Hints Author: Guido van Rossum <guido at python.org>, Jukka Lehtosalo <jukka.lehtosalo at iki.fi>, Łukasz Langa <lukasz at python.org> BDFL-Delegate: Mark Shannon Discussions-To: Python-Dev list Status: Final Type: Standards Track Topic: Typing Created: 29-Sep-2014 Python-Version: 3.5 Post-History: 16-Jan-2015, 20-Mar-2015, 17-Apr-2015, 20-May-2015, 22-May-2015 Resolution: Python-De
Andrew Montalenti @amontalenti – Parse.ly Founder. Coding in Python, JavaScript, Clojure, & C. Menu and widgets In 2010, the Python core team wrote PEP 3107, which introduced function annotations for Python 3.x. Nearly 4 years ago, I wrote this response to the PEP, but I published it to a discussion site that ended up becoming defunct (Clusterify). I saw that recently, interest in function annotat
デフォルト引数周りの型のことでちょっと把握できなかった部分があったのでメモ。 余分なデフォルト引数を持つ実装について 例えば、以下の様なプロトコルがあるとする。 import typing as t import typing_extensions as tx class Adder(tx.Protocol): def add(self, x: int, y: int) -> int: ... このAdder.addメソッドはデフォルト引数を持たない。一方で、デフォルト引数を持つような実装はこのプロトコルの制約を満たすのかということが気になる。 例えば以下のようなもの class A: def add(self, x: int, y: int, *, verbose: bool = False) -> int: return x + y class B: def add(self, x:
# For most types, just use the name of the type in the annotation # Note that mypy can usually infer the type of a variable from its value, # so technically these annotations are redundant x: int = 1 x: float = 1.0 x: bool = True x: str = "test" x: bytes = b"test" # For collections on Python 3.9+, the type of the collection item is in brackets x: list[int] = [1] x: set[int] = {6, 7} # For mappings
Python Requirements¶ PyOxidizer currently targets Python 3.8 or 3.9. Your Python application will need to already be compatible with 1 of these versions for it to work with PyOxidizer. See Why is Python 3.8 Required? for more on the minimum Python requirement. Operating System Requirements¶ PyOxidizer itself is a Rust program and should theoretically be installable on any environment that Rust sup
Too Long; Didn't ReadThe <em>underscore</em> (_) is special in Python. I’m not a native speaker. Sorry for my english. Please understand. The underscore (_) is special in Python. While the underscore (_) is used for just snake-case variables and functions in most languages (Of course, not for all), but it has special meanings in Python. If you are python programmer, for _ in range(10) , __init__(s
Fifteen years ago, there were only a few skills a software developer would need to know well, and he or she would have a decent shot at 95% of the listed job positions. Those skills were: Object-oriented programming.Scripting languages.JavaScript, and…SQL.SQL was a go-to tool when you needed to get a quick-and-dirty look at some data, and draw preliminary conclusions that might, eventually, lead t
Data Pre-Processing in Python: How I learned to love parallelized applies with Dask and Numba If you’re comfortable with using Pandas to transform data, create features, and perform cleaning, you can easily parallelize your workflow with Dask and Numba.In pure speed: Dask beats Python, Numba beats Dask, Numba+Dask beats ’em allInstead of using a Pandas apply, separate out numerical calculations in
One of the most common complaints about the Python language is that variables are Dynamically Typed. That means you declare variables without giving them a specific data type. Types are automatically assigned at based on what data was passed in: In this case, the variable president_name is created as str type because we passed in a string. But Python didn’t know it would be a string until it actua
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く